Relational
Lua's relational operators are more or less the same as in most other languages:
local x = 2
local y = 3
print(x > y) -- False
print(x < y) -- True
print(x >= y) -- False
print(x <= y) -- True
print(x <= x) -- True
print(x >= x) -- True
The relational operators allow one to determine when values are greater-than or less-than others, and include a variant that also allows the variables to be equal.
Equality
Lua's equality operator uses two equal signs ==, which is differentiated from the
variable assignment operator = which uses a single equal sign:
local x = 2
local y = 3
print(x == y) -- False
print(x == x) -- True
This operator returns true when the two values are equal, otherwise it returns false.
Inequality
Like equality, it can often be useful to know when two values are not equal. Lua implements this
using the ~= operator:
local x = 2
local y = 3
print(x ~= y) -- True
print(x ~= x) -- False
This operator returns false when the two values are equal, otherwise it returns true.