An expression is something that represents a value. It can include numeric constants, quoted strings, variable names, unary and binary operations, and function calls.
+
, -
, *
, /
, %
, and ^
are called arithmetic operators.
Here is an example of binary arithmetic operators:
t = 2*(2-5.5)/13+26 print(t) -- 25.461538461538
An example of the modulo (division remainder) operator is as follows:
m = 18%4 print(m) -- 2
An example of the power of operator is as follows:
n = 7^2 print(n) -- 49
Relational operators always result in false or true and ask yes or no questions. The relational operators are <
, >
, <=
, >=
, ==
, ~=
.
The ==
operator tests for equality, and the ~=
operator tests for inequality. If the value types are different, then the result is false. Otherwise, Lua compares the values to their types. Numbers and strings are compared in the usual way. Tables and functions are compared by reference as long as two such values are considered...