Ternary in lua is bad. Any time you do a ternary operation you are interacting with an implicit boolean which can introduce unwanted behaviors if you aren’t paying attention. Also, since lua ternary uses logic operators
or, it can be difficult to tell at a glance if logical operation is just a ternary operation.
Consider the canonical lua ternary structure:
result = condition and success or failure
This structure doesn’t support a
nil success value, because it will be overridden by the
or failure. Another failure of this structure is that it must evaluate both
condition succeeds, adding unnecessary processing time. This can be significant if your success and failure values are function calls.
So my suggestion is to add a typical ternary operator to luau:
result = condition ? success : failure
In a traditional ternary structure,
failure will not even be evaluated if
condition is true. The code branches within the structure so that unintended evaluations and logical operations are avoided.