Operators and Expressions
Lua provides standard arithmetic, comparison, logical, and string operators.
Arithmetic Operators:
+ -- addition
- -- subtraction
* -- multiplication
/ -- division
^ -- exponentiation
% -- modulus
Example:
a = 10
b = 3
print(a + b) -- 13
print(a ^ b) -- 1000 (10 to the power of 3)
Relational Operators:
== -- equal
~= -- not equal
> -- greater than
< -- less than
>= -- greater than or equal
<= -- less than or equal
Logical Operators:
and or not
String Concatenation:
Use ..
to concatenate strings:
greeting = "Hello" .. " " .. "World"
print(greeting) -- Hello World