GenerativeComponents Help

Precedence of Operators

It is common for an expression to include different kinds of operators (i.e., chain calculations).

By default, when multiple operators appear within an expression, they're calculated in the following sequence. (Operators with a lower-numbered precedence level are calculated first.)

When multiple operators at the same precedence level appear in sequence within an expression, they're calculated from left to right, unless otherwise noted.

Precedence Level Operators
1

x.y                    qualification

x[y]                  indexing

x(y)                  function call

2

x++                   increment (postfix)

x--                    decrement (postfix)

3 (If more than one of these operators appears in sequence within an expression, they're calculated from right to left instead of from left to right.)

-x                     negate

++x                  increment (prefix)

--x                   decrement (prefix)

!x                     not

~x                    complement

4

x * y               multiply

x / y               divide

x \ y               floored integer divide

x % y               modulo

5

x + y               add; concatenate

x – y               subtract

6

x << y             shift left

x >> y             shift right

7

x < y               test for relative order

x > y

x <= y

x >= y

x is type      test for data type

x as type

8

x == y             test for equality

x != y             test for inequality

9

x & y               and

10

x ^ y               exclusive or

11

x | y               or

12

x && y             and ('short circuiting' form)

13

x || y             or ('short circuiting' form)

14 (If more than one of these operators appears in sequence within an expression, they're calculated from right to left instead of from left to right.)

x ? y : z      conditional

15

These 'variable operators' are covered in the next section, Variables.

(If more than one of these operators appears in sequence within an expression, they're calculated from right to left instead of from left to right.)

x += y           assign add

x -= y            assign subtract

x *= y            assign multiply

x /= y             assign divide

x \= y             assign floored integer divide

x %= y           assign modulo

x &= y           assign and

x |= y             assign or

x ^= y            assign exclusive or

x <<= y          assign shift left

x >>= y          assign shift right