zl程序教程

您现在的位置是:首页 >  其他

当前栏目

lua and or not 逻辑运算符

逻辑 not and or 运算符 lua
2023-09-27 14:21:31 时间

按 c 风格写多条件判断,会出异常, 如  if ( cond1& cond2 ){ do something; };

lua写成 

if  cond1 and cond2 then

     do something

end

这样会出异常, 当 cond1 为false时直接返回 cond2 的值, cond2 true就会执行 do something了。

需要改为  

if  cond1 == true and cond2 == true then

     do something

end