Using Director > Writing Scripts with Lingo > Using operators to manipulate values > Understanding operator precedence |
![]() ![]() ![]() |
Understanding operator precedence
When two or more operators are used in the same statement, some operators take precedence over others in a precise hierarchy that Lingo follows to determine which operators to execute first. This is called the operators' precedence order. For example, multiplication is always performed before addition. However, items in parentheses take precedence over multiplication. For example, without parentheses, Lingo performs the multiplication in this statement first:
total = 2 + 4 * 3
The result is 14.
When parentheses surround the addition operation, Lingo performs the addition first:
total = (2 + 4) * 3
The result is 18.
Descriptions of the operators and their precedence order follow. Operators with higher precedence are performed first. For example, an operator whose precedence order is 5 is performed before an operator whose precedence order is 4. Operations that have the same order of precedence are performed left to right.
![]() ![]() ![]() |