AND in Lua, how is it processed?

依然范特西╮ 提交于 2019-12-01 21:07:15

From the docs:

The operator and returns its first argument if it is false; otherwise, it returns its second argument.

Therefore, true and "YES!" evaluates to "YES!".

This scheme works because if the first argument is falsy, the whole expression will become falsy (the same as the first argument); otherwise it will become the same as the second argument, which iff that is truthy will make the whole expression truthy.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!