Skip to content

Operator precedence

The operator precedence and expression ordering is as follows, going from strong to weak. Binary operators at the same precedence level are grouped in the order given by their associativity.

Expression type Associativity
Name
Unary +, -, &, *
as
*, /, % Left
+, - Left
>>, >>>, << Left
& Left
^ Left
| Left
>, <, >=, <= Left
==, != Left
&& Left
|| Left
.. Not allowed together1
..= Not allowed together1
=, +=, -=,
*=, /=, %=,
>>=, >>>=, <<=,
&=, ^=, |=
Right

Comparison and equality operator chaining

For example, we need to check if the value of x is greater than 10 and below 20. These are two conditions; in most languages this would be 10 < x && x < 20.

However, in Nite, groups of comparison or equality operators can be chained.

x == y != z
Is equivalent to
x == y && y != z

x < y > z
Is equivalent to
x < y && y > z


  1. Syntax x..y..z will cause an error. You need to put parentheses to explicitly define associativity. ↩↩