When the interpreter executes an expression it evaluates each operator it in a certain order. It is easy to write an expression which has an unclear order of evaluation. For instance, the expression A - B + C could be parsed as A - B followed by the result plus C or as A minus B + C. To resolve these ambiguities, each operator has two properties when interpreted: precedence and association.
Precedence determines whether an operator is more important than another operator; for instance, A + B * C is equivalent to A + (B * C) because multiplication has higher precedence (is more important) than addition.
Association determines whether operators at the same precedence level associate left to right or right to left; A - B - C is equivalent to (A - B) - C because subtraction associates left to right.
Here is a list of operators grouped by precedence, in order from highest to lowest:
[] . -- ++ ! - (unary) * / % + - (binary) == != > >= < <= in && || ?: = += -= /= *= ?=
All operators associate from left to right except the Logical Operators (&&, ||, and ?|), which associate from right to left. Parentheses may be used to group expressions and clarify evaluation.
Operator Precedence | Index Operators | Arithmetic Operators | Assignments | Logical Operators | Conditional | List Splice Operator