LuaBooleans in Lua


Booleans, truth, and falsity are straightforward in Lua. To review:

  1. There is a boolean type with exactly two values: true and false.
  2. In a conditional context (if, elseif, while, until), a boolean is not required. Any expression can be used.
  3. In a conditional context, false and nil count as false, and everything else counts as true.
  4. Although 3 already implies this: if you're coming from other languages, remember that 0 and the empty string count as true in conditional contexts in Lua.