Same in Lua. Only nil and false are treated as falsy, everything else is treated as truthy. The idea is that by default everything that is not nil is treated as true because it exists, and false is a special case used to represent false propositions.
It can be a bit of a stumbling block coming from some other languages, but the rule is so simple that you get used to it quickly.
53
u/redlaWw 19h ago
Same in Lua. Only
nilandfalseare treated as falsy, everything else is treated as truthy. The idea is that by default everything that is notnilis treated as true because it exists, andfalseis a special case used to represent false propositions.It can be a bit of a stumbling block coming from some other languages, but the rule is so simple that you get used to it quickly.