tutorials

Tech stack collection about Tutorials Point -

View the Project on GitHub

Operators

An operator is a symbol that tells the interpreter to perform specific mathematical or logical manipulations. Lua language is rich in built-in operators and provides the following type of operators −

This tutorial will explain the arithmetic, relational, logical, and other miscellaneous operators one by one.

Arithmetic

A = 10, B = 20

Relational

Example

(A == B) is not true. (A ~= B) is true. (A > B) is not true. (A < B) is true. (A >= B) is not true. (A <= B) is true.

Logical

Misc

Miscellaneous operators supported by Lua Language include concatenation and length.

a..b where a is “Hello “ and b is “World”, will return “Hello World”.

#"Hello" will return 5

Operators Precedence

Operator precedence determines the grouping of terms in an expression. This affects how an expression is evaluated. Certain operators have higher precedence than others.

Here, operators with the highest precedence appear at the top of the table, those with the lowest appear at the bottom. Within an expression, higher precedence operators will be evaluated first.