SwiftSemantics Documentation Beta

Enumeration Precedence​Group.​Associativity

public enum Associativity

The associativity of an operator, which determines how operators of the same precedence are grouped in the absence of parentheses.

Consider the expression a ~ b ~ c: If the ~ operator is left-associative, then the expression is interpreted as (a ~ b) ~ c. If the ~ operator is right-associative, then the expression is interpreted as a ~ (b ~ c).

For example, the Swift subtraction operator (-) is left-associative, such that 5 - 7 - 2 evaluates to -4 ((5 - 7) - 2) rather than 0 (5 - (7 - 2)).

%3 PrecedenceGroup.Associativity PrecedenceGroup.Associativity Hashable Hashable PrecedenceGroup.Associativity->Hashable Codable Codable PrecedenceGroup.Associativity->Codable String String PrecedenceGroup.Associativity->String

Member Of

PrecedenceGroup

An operator precedence group declaration.

Conforms To

Codable
Hashable
String

Enumeration Cases

left

case left

Left-associative (operations are grouped from the left).

right

case right

Right-associative (operations are grouped from the right).

Initializers

init?(_:​)

public init?(_ node: PrecedenceGroupAssociativitySyntax)

Creates an instance initialized with the given syntax node.