Operators that bound tighter (higher precedence) are listed first.
Operators | Precedence group (≥3.0) | Precedence | Associativity |
---|---|---|---|
. | ∞ | left | |
? , ! , ++ , -- , [] , () , {} | (postfix) | ||
! , ~ , + , - , ++ , -- | (prefix) | ||
~> (swift ≤2.3) | 255 | left | |
<< , >> | BitwiseShiftPrecedence | 160 | none |
* , / , % , & , &* | MultiplicationPrecedence | 150 | left |
+ , - , | , ^ , &+ , &- | AdditionPrecedence | 140 | left |
... , ..< | RangeFormationPrecedence | 135 | none |
is , as , as? , as! | CastingPrecedence | 132 | left |
?? | NilCoalescingPrecedence | 131 | right |
< , <= , > , >= , == , != , === , !== , ~= | ComparisonPrecedence | 130 | none |
&& | LogicalConjunctionPrecedence | 120 | left |
|| | LogicalDisjunctionPrecedence | 110 | left |
DefaultPrecedence* | none | ||
? ...: | TernaryPrecedence | 100 | right |
= , += , -= , *= , /= , %= , <<= , >>= , &= , |= , ^= | AssignmentPrecedence | 90 | right, assignment |
-> | FunctionArrowPrecedence | right |
DefaultPrecedence
precedence group is higher than TernaryPrecedence
, but is unordered with the rest of the operators. Other than this group, the rest of the precedences are linear.