--[[
运算符
1. 算数运算符
+ - * / % ^幂
2. 关系云算法
== >= <= ~=不等于
3. 逻辑运算符
and 与 等于 && 都为true
or 或 等于 || 有一个为true,则true
not 非 等于 ! a为true,not a 则取反 为 false
--]]
算数运算符:
x,y =2,4
s = x+y
print(s)
s = x-y
print(s)
s = x*y
print(s)
s = x/y
print(s)
s = x%y
print(s)
s = x^y
print(s)
关系运算符
x,y =2,4if(x ~= y)thenprint("不等於")end
逻辑运算符
x,y =2,falseif( x and y)thenprint("与")elseprint("与X")endif( x or y)thenprint("或")elseprint("与")endif(not y)thenprint("非")endif( x and(not y))thenprint("与")elseprint("与X")end
or 相当于条件表达式
x,y =2,false
z = x or{}print(z)--输出 2
x =nil
z = x
print(z)--输出 nil
z = x or{}print(z)--输出 table: 002FB788