Operators and Expressions
Lua provides standard arithmetic, comparison, logical, and string operators.
Arithmetic Operators:
+ -- addition
- -- subtraction
* -- multiplication
/ -- division
^ -- exponentiation
% -- modulusExample:
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 equalLogical Operators:
and or notString Concatenation:
Use .. to concatenate strings:
greeting = "Hello" .. " " .. "World"
print(greeting) -- Hello World