Operator Precedence

Table 5, Operator precedence shows all the Erlang operators in order of descending priority together with their associativity. Operator precedence and associativity are used to determine the evaluation order in unparenthesized expressions.

Table 5. Operator precedence

Operators

Associativity

:

#

(unary) +, (unary) -, bnot, not

/, *, div, rem, band, and

Left associative

+, -, bor, bxor, bsl, bsr, or, xor

Left associative

++, - -

Right associative

==, /=, =<, <, >=, >, =:=, =/=

andalso

orelse

= !

Right associative

catch

Expressions with higher priority (higher up in the table) are evaluated first, and then expressions with lower priority are evaluated. So, for example, to evaluate 3+4*5+6, we first evaluate the subexpression 4*5, since ( ...

Get Programming Erlang, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.