# 安装sudo apt install tealangsudo brew install tealangsudo yum install tealang# 运行tea run app.teatea install dependency # 引入依赖import http os# 赋值与数据类型a1 = 1 # 整数a2 = "a" # 字符串a3 = true # 布尔" />
  • 35648

    文章

  • 23

    评论

  • 20

    友链

  • 最近新加了很多技术文章,大家多来逛逛吧~~~~
  • 喜欢这个网站的朋友可以加一下QQ群,我们一起交流技术。

Tea: 一门新的编程语言

欢迎来到阿八个人博客网站。本 阿八个人博客 网站提供最新的站长新闻,各种互联网资讯。 喜欢本站的朋友可以收藏本站,或者加QQ:我们大家一起来交流技术! URL链接:https://www.abboke.com/jsh/2019/0808/104671.html 1190000020002723nd">
# 安装
sudo apt install tealang
sudo brew install tealang
sudo yum install tealang

# 运行
tea run app.tea
tea install dependency
# 引入依赖
import
    http
    os

# 赋值与数据类型
a1 = 1 # 整数
a2 = "a" # 字符串
a3 = true # 布尔
a4 = null # 空
a5 = 1.1 # 浮点
a6 = [a1 a2 a3] # 列表
a7 = {name: "Elliot" age:26} # 字典
a8 = (a1 a2 a3) # 元组
a9 = {a1 a2 a3} # 集合

# 基本运算
+,-,*,/,%,^,&,|,!,==,>=,<=,>,<,~,?

# 函数
hello name: "Hello {name}"
default   : "Hello World"
main arg1 arg2...:
    print arg1
    print arg2

# 类
Myclass object:
    attibute = "class attibute"

    __init name:
        .name = name
        ._private = 1
    __str:.name
    show:.name


# 判断
i = 0
if   i == 0
    hello i
elif 20 > i > 10
    default
else
    exit

# 循环
for i ~ 0:10 print i
for k v ~ {"name": "Elliot"}
    print k
    print v

# 推导式

print i for i ~ ["a" "b" "c" "d"]
print i for i ~ 0:10
0:10:2 = [0 2 4 6 8]

# 数组切片

[0 1 2 3 4 5][0:2]      = [0 1]
[0 1 2 3 4 5][-2:-0]    = [4 5]

# 异步函数
async callme: "Async Hello World"
await [callme callme callme callme]

# 解构赋值

theBait   = 1000
theSwitch = 0

[theBait theSwitch] = [theSwitch theBait]

futurists = {
    sculptor:"Umberto Boccioni"
    painter:"Vladimir Burliuk"
    poet: {
        name:"Tom"
        address:["Via Roma 42R" "Bellagio, Italy 22021"]
    }
}

{poet: {name, address: [street, city]}} = futurists

tag = "<impossible>"
[open contents... close] = tag.split

# 异常捕获
try
    something
catch ValueError
    print "Value is wrong."
catch CustomError
    print "CustomError"
else
    print error
finally
    anything

相关文章

暂住......别动,不想说点什么吗?
  • 全部评论(0
    还没有评论,快来抢沙发吧!