July 2018
Beginner
202 pages
5h 42m
English
Logical operators test the relationship of two statements. Logical operators work a little differently in Lua than in other languages. In Lua, anything not false is considered to be true. Only two values represent false for a logical operator, the constant value of false and nil; anything else is true.
The and operator returns its first operand if that operand is false and the second operand if the first operand was true. Here is an example:
x = true and false -- value is falsey = false and false -- value is falsez = true and true -- value is truew = 7 and 1 -- value is 1
The or operator (or) returns its second ...