首页 > 其他 > 详细

lua 之 and or not

时间:2014-02-27 13:08:36      阅读:499      评论:0      收藏:0      [点我收藏+]

and是与运算,返回值如下

   如果前者为false或者nil,则返回前者,否则后者

A and B

类似如下语句

if not A then

return A

else

return B

end

 

总结:and运算只要前者不为false或者nil ,均返回后者

运行截图:

bubuko.com,布布扣

-------------------------------------------------------

or是或运算,返回值如下:

  如果前者为真返回前者,否则返回后者

A or B

相当于以下代码

if A then

return A

else

return B

end

 

总结:or运算,只要前者不是false或者nil,就返回前者。否则返回后者

运行截图:

bubuko.com,布布扣

 ---------------------------------------------------------

not 运算是非运算,返回值如下:

  如果真,返回假,如果假,返回真

这个运算相当于c语言中的 !运算

bubuko.com,布布扣

lua 之 and or not,布布扣,bubuko.com

lua 之 and or not

原文:http://www.cnblogs.com/dzqdzq/p/3569542.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!