# 安装
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

已注销
981 声望48 粉丝

Focus on programming efficiency