Operators and symbols
Infix operators
This list contains all the infix operators, an example of how the operator would be used, a short explanation, and its precedence. An operator with a higher precedence will be grouped before an operator with less precedence.
Operator | Example | Explanation | Precedence |
---|---|---|---|
in | a in [] | Membership operator | 1 |
.. | 0..10 | Range generation | 2 |
|| | true || false | Logic OR | 3 |
&& | true && false | Logic AND | 4 |
> | 1 > 0 | "Greater" comparison | 5 |
>= | 1 >= 0 | "Greater or equal" comparison | 5 |
< | 1 < 0 | "Less" comparison | 5 |
<= | 1 <= 0 | "Less or equal" comparison | 5 |
/= | 9 /= 9 | Negated equality | 5 |
= | 'a' = 'a' | Equality | 5 |
^ | 2 ^ 3 | Bitwise XOR | 6 |
& | 1 & 0 | Bitwise AND | 7 |
<< | 1 << 2 | Left shift | 8 |
>> | 8 >> 2 | Right shift | 8 |
- | 8 - 3 | Arithmetic substraction | 9 |
+ | 1 + 1 | Arithmetic addition | 9 |
/ | 1 / 2 | Arithmetic division | 10 |
% | 5 % 7 | Division remainder | 10 |
* | 5 * 7 | Arithmetic multiplication | 10 |
** | 2 ** 5 | Exponentiation | 11 |
Prefix operators
This list contains all the prefix operators, an example of how the operator would be used, and a short explanation.
Operator | Example | Explanation |
---|---|---|
~ | ~1 | Bitwise negation |
! | !false | Logic negation |
- | -5 | Additive inverse |