The relational operators in Lua are
== ~= < > <= >=
These operators always result in false or true.
==) first compares the type of its operands.
If the types are different, then the result is false.
Otherwise, the values of the operands are compared.
Numbers and strings are compared in the usual way.
Objects (tables, userdata, threads, and functions)
are compared by reference:
two objects are considered equal only if they are the same object.
Every time you create a new object
(a table, userdata, thread, or function),
this new object is different from any previously existing object.
You can change the way that Lua compares tables and userdata
by using the "eq" metamethod (see §2.8).
The conversion rules of §2.2.1
do not apply to equality comparisons.
"0"==0 evaluates to false,
t["0"] denote different
entries in a table.
~= is exactly the negation of equality (
The order operators work as follows.
If both arguments are numbers, then they are compared as such.
Otherwise, if both arguments are strings,
then their values are compared according to the current locale.
Otherwise, Lua tries to call the "lt" or the "le"
metamethod (see §2.8).
a > b is translated to
b < a
a >= b is translated to
b <= a.