quote: For example, lua has no ternary operator ( condition ? true : false ) which is commonly used in C, and does not support using numbers in conditionals (if numberOfSomethings then ... ) |
Lua by nature is itself very similar to a ternary operation.
local value = condition and valueiftrue or valueiffalse
-- only caveat is that valueiftrue doesn't evaluate false
Lua does support numbers (and anything) as conditionals. The difference from other languages is it doesn't evaluate 0 as false. While in C functions are designed to return 0 on an error or not-found scenario for use in a condition, in Lua they instead return false. The resulting usage of the return value is just as concise.