Logic

Lua knows three logical operators;, , and. These operators are used to create conditional statements that return true or false. In Lua, false and nil are considered falsey, all other values are considered truthy.

not
not is a logic operator that will negate a boolean expression. will become and vice versa.

print(not true) will output. print(not false) will output.

and
and is a logic operator that will evaluate two boolean expressions, and returns only when both expressions are.

print(true and false) will output. print(true and true) will output.

or
or is a logic operator that will return if any of the given two expressions are.

print(false or false) will output print(false or true) will output

Conditional expressions
In many languages it is possible to inline simple if-statements as expressions. For example, in Java, this can be done using the ternary operator. While such an operator does not exist in Lua, it can be simulated using a combination of the and  operators, by following the pattern. For instance:

will initialise with. will initialise with.

This works because of short-circuit evaluation.