lua and or not 逻辑运算符

按 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

具体参考lua 的 and 和or 用法

http://blog.csdn.net/heyuchang666/article/details/51005550

 
posted @ 2017-12-02 15:45  decode126  阅读(4723)  评论(0编辑  收藏  举报