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

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM