Lua逻辑运算符

2017-08-14  本文已影响0人  YellowFish

Lua逻辑运算符

and or not --对应c#的 && || !
if 0 then
    print("do it")
end

--输出结果 do it
if false then
    print("do it")
end
--输出结果 (无)
if nil then
    print("do it")
end
--输出结果 (无)

Lua和C#逻辑运算符的异同

CSharp###

a && b  //如果a为false,b为true,返回false.

lua

a and b -- 如果a为false,则返回a,否则返回b

a or b -- 如果a为true,则返回a,否则返回b
上一篇 下一篇

猜你喜欢

热点阅读