print("-------------特殊用法------------------")
print("-------------多变量赋值------------------")
a,b,c=1,2,3
print(a)
print(b)
print(c)
a,b,c=1,2
print(a)
print(b)
print(c)--如果后面的值不够,会自动补空,多了会自动省略
print("-------------多返回值------------------")
function Test( )
-- body
return 10,20,30,40
end
a,b,c=Test()
print(a)
print(b)
print(c)
a,b,c,d,e=Test()
print(a)
print(b)
print(c)
print(d)
print(e)
print("-------------and or------------------")
--and or 可以连接任何东西 只有nil和false才认为是假
print(1 and 2)
print(0 and 1)--注意和C++不一样
print(nil and 1)
print(false and 1)
print(1 or 2)
---lua不支持三目运算符
x=3
y=2
local res = (x>y) and x or y
print(res)--[[
(x>y) and x -->x
x or y -->x
]]
x=1
y=2
local res = (x>y) and x or y
print(res)--[[
(x>y) and x -->false
false or y -->y
]]