Skip to content
This repository has been archived by the owner on Oct 17, 2021. It is now read-only.

PrecedenceGroup_Associativity

Mattt edited this page Aug 2, 2020 · 6 revisions

PrecedenceGroup.Associativity

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

public enum Associativity

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)).

Inheritance

Codable, Hashable, String

Initializers

init?(_:​)

Creates an instance initialized with the given syntax node.

public init?(_ node:​ PrecedenceGroupAssociativitySyntax)

Enumeration Cases

left

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

case left

right

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

case right
Clone this wiki locally