An expression is something that has a value. It can include numeric constants, quoted strings, variable names, unary and binary operations, and function calls.
+
, -
, *
, /
, %
, and ^
are called arithmetic operators.
The following is an example using Binary arithmetic operators:
t = 2*(2-5.5)/13+26 print(t) -- 25.461538461538
The following is an example using the Modulo (division remainder) operator:
m = 18%4 print(m) -- 2
The following is an example using the Power of operator:
n = 7^2 print(n) --49
Relational operators always result in false
or true
and ask yes-or-no questions.
<
, >
, <=
, >=
, ==
, and ~=
are some of the relational operators.
The operator ==
tests for equality and the operator ~=
is the negation of equality. 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,...