Operator Precedence
The logical operators && and || both return the value that makes
them true, not just a boolean true or false. For example, &Foo :=
(User-Password || "help") returns the value of User-Password if it
exists, or else the string "help" if it does not.
If a math operation causes an overflow, underflow, or division by
zero, it returns no result. This impacts the rest of the
calculation. You can use the || operator to replace a missing result
with a different value.
Use parentheses ( ) to wrap a nested expression. They also help
clarify policies and define the order of evaluation.
The following tables summarises the order of precedence of the v4 operators.
| Priority | Operator(s) | Category | Notes |
|---|---|---|---|
1 (highest) |
|
Grouping |
Overrides all other precedence. |
2 |
|
Logical NOT / Unary |
Prefix negation; also bitwise |
3 |
|
XOR |
|
4 |
|
Arithmetic |
Standard multiply, divide, modulo. |
5 |
|
Arithmetic |
Addition/subtraction and also string/octet concatenation. |
6 |
|
Bitwise shift left/right |
bit shift |
8 |
|
Binary OR |
Also string/octet OR |
7 |
|
Binary AND |
Also works on |
9 |
|
Comparison |
Produces a boolean result. The |
10 |
&& |
Logical AND |
Short-circuits and also returns the value that caused success. |
11 (lowest) |
|
Logical OR |
Short-circuits and can also be used to replace null results. |
|
The |