Language reference · section 6

6. Operator precedence

From lowest to highest. Operators in one row have the same precedence.

Level Operators Grouping
1 (params) -> expr, async (params) -> expr the body is an expr
1 if c then a else b the condition is a pipe
2 |> left
3 ?? left
4 or left
5 and left
6 is, isnt, in left
7 <, <=, >, >= a chain when there is more than one
8 +, - left
9 *, /, % left
10 ** right
11 prefix -, not, await right
12 call f(...), index a[i], member a.b, optional member a?.b left
13 literals, names, groups (...), arrays, objects

Examples:

Feature: Precedence

  Scenario: and binds tighter than or
    Given the code "x = true or false and false"
    Then x is true

  Scenario: Exponentiation is right associative
    Given the code "x = 2 ** 3 ** 2"
    Then x is 512

  Scenario: The pipe passes the value as the first argument
    Given the code "a |> f(b)"
    Then the code calls f(a, b)

  Scenario: Pipes chain from left to right
    Given the code "raw |> trim |> split(\",\")"
    Then the code calls split(trim(raw), ",")