< Nil | UserGuide | Number >


Boolean values

A boolean value describe a value that is either true or false. Boolean values can be used with boolean operators only and are evaluated to boolean values again.

However, boolean values are not necessarily required in lua. Following codes will result in the same output:

if true then print "one" end
if false then print "two" end
if false or true then print "three" end
if not false and true then print "four" end

if 0 then print "one" end
if nil then print "two" end
if nil or "ok" then print "three" end
if not nil and 1 then print "four" end

Both sources will print

one
three
four

Any value in Lua that is not false or not nil will be evaluated as false, while all other values will be evaluated as true (even the number 0 will be evaluated as true, unlike as in some other programming languages).