Expression operator precedence
The following table lists the primary and bitwise expression operators in order by their precedence, from lowest to highest. See also
Event expression operator precedence.
Operation | Operator | Precedence |
Logical or bitwise union | or | 1 |
Logical or bitwise exclusive or | xor | 2 |
Logical or bitwise intersection | and | 3 |
Unary logical or bitwise inverse | not | 4 |
Relational | <, <=, >, >=, !=, = | 5 |
Additive | +, – | 6 |
String concatenation | + | 6 |
Multiplicative | *, /, % | 7 |
Unary additive | +, – | 8 |
Cast | <type> | 9 |
Name qualifier (dot) | . | 10 |
Object constructor | new | 10 |
Subscript | [ ] | 10 |
Action call | actionName() | 11 |
Parenthesized expression | ( ) | 11 |
Stream query | from | 11 |
Stream source template | all | 11 |
For clarity, it is strongly recommended to use brackets in expressions. This makes it very easy to understand what an expression means. For example:
(10 * 10) > (9 * 9)
Do not use un-bracketed expressions, except where trivial. The following is equivalent to the above expression and is just about acceptable:
10 * 10 > 9 * 9
It is bad practice, however, to use an expression such as the following as it relies on intimate knowledge of the precedence:
1 + 2 - 3 * 4 / 5 < -1 or 5