算术运算符
"+" 当数字和字符串相加的时候,会尝试把字符串转换为数值来运算 print("10" + 5) 输出15.0
"-"
"*"
"/"
"%"
"^" 幂
"- "
local a = 10
print(a ^ 2)
输出: 100
关系运算符
"=="
"~=" 不等
">"
"<"
">="
"<="
逻辑运算符
a = true, b = false
and 逻辑与, 都为ture,结果为true。 a and b 为false
or 逻辑或,一个为true,结果为true。 a or b 为true
not 逻辑非,对逻辑结果取反。 not(a and b ) 为true, not(a) 为false
其他运算符
".." 字符串连接
字符串连接,lua 中 .. 来拼接字符串
print("name=" .. "jayden" )
"#" 字符串长度或者表的长度
local tb = {1,2,3,4}
print(#tb)
print(#"name=jayden")
所有运算符的运算优先级从高到低是
"^"
"not" "-" (负数)
"*" " /"
"+" " -"
".."
"<" " >" "<=" " >=" "~= " "=="
"and"
"or"