The local a=true
Print (a==true and false or true)
So whether a true or false, the output is true
I put the code into the
The local a=true
Print (not a)
It's good that
Haven't figured out why the first kind of ternary expression is no good?
CodePudding user response:
This is related to a operator precedence relations, I give you add parentheses you see (((a==true) and false) or true) that is equivalent to (or true), no matter what is a, this expression is return trueCodePudding user response:
https://blog.csdn.net/fightsyj/article/details/84559328CodePudding user response:
The problem of operator precedenceCodePudding user response:
Or trueCodePudding user response:
Lua is not the ternary operator, by "and" and "or" is actually composed of pseudo three purpose, main is to use lua "and" and "or" characteristics, the building Lord indeed written expression is the return value is true,CodePudding user response:
A and B or C: B not to falsehttps://blog.csdn.net/fightsyj/article/details/84559328
CodePudding user response:
This question actually have the answers online, is the problem of priorityhttps://blog.csdn.net/coffeecato/article/details/77546887
CodePudding user response:
Operator precedenceCodePudding user response:
The problem of priority,,,CodePudding user response:
Want to add parentheses, habits or occasional problems often...