Operator precedence
The precedence of an operator determines the order in which is applied when
more than one operator is present in an expression. For example, multiplication
(*) has higher precedence than addition (+) so the expression:
1 + 4 * 5
evaluates to 21.
Parentheses may be used to force precedence, when desired. For example:
(1 + 4) * 5
evaluates to 25.
Associativity
When operators have equal precedence, they are evaluated from left to right.
For example, the following expression evaluates to -8:
1 - 4 - 5
Precedence of all operators
All available Inkling operators are listed below in order of highest precedence to lowest precedence.
| Operators | Details |
|---|---|
+ - (unary) |
Casts a number to be positive (+) or negative (-) |
not |
Logical Operators |
** |
Arithmetic Operators |
* / % |
Arithmetic Operators |
+ - (binary) |
Arithmetic Operators |
< <= > >= |
Comparison Operators |
== != |
Comparison Operators |
and |
Logical Operators |
or |
Logical Operators |