> E.g. true and false or 42 returns 42, whereas true ? false : 42 returns the (expected) false.
x = a ? b : c # x is b, same as you would if a {x=b} else {x=c}
lua and/or a,b,c = true, 1, 2
x = a and b or c -- x is b
a,b,c = true, false, 2
x = a and b or c -- x is c
The or is dependent on its previous operand, so b will return false and skips to c, even if you meant for it to be b. you must use an if then else. However, you can have more than a ternary, if there is no need for short-circuit evaluation, as in, any of the operand is not a function CALL like c(), and you want to remain inside an expression, then you can do this insteadselect (select is a native C function, this is faster than the table creation below)
x = select(a and 1 or 2, b, c)
table creation/selection x = ({false,2})[a and 1 or 2]
of course, doing something like local x; if a then x=b else x=c end
does not look so bad