Represents a hash pattern in pattern matching.

foo => { a: 1, b: 2 }
       ^^^^^^^^^^^^^^

foo => { a: 1, b: 2, **c }
       ^^^^^^^^^^^^^^^^^^^

foo => Bar[a: 1, b: 2]
       ^^^^^^^^^^^^^^^

foo in { a: 1, b: 2 }
       ^^^^^^^^^^^^^^
Attributes
Read

Represents the optional constant preceding the Hash.

foo => Bar[a: 1, b: 2]
     ^^^

foo => Bar::Baz[a: 1, b: 2]
     ^^^^^^^^
Read

Represents the explicit named hash keys and values.

foo => { a: 1, b:, ** }
         ^^^^^^^^
Read

Represents the rest of the Hash keys and values. This can be named, unnamed, or explicitly forbidden via **nil, this last one results in a NoKeywordsParameterNode.

foo => { a: 1, b:, **c }
                   ^^^

foo => { a: 1, b:, ** }
                   ^^

foo => { a: 1, b:, **nil }
                   ^^^^^
Class Methods

Initialize a new HashPatternNode node.

Return a symbol representation of this node type. See Node::type.

Instance Methods

Implements case-equality for the node. This is effectively == but without comparing the value of locations. Locations are checked only for presence.

def accept: (Visitor visitor) -> void

def child_nodes: () -> Array

def closing: () -> String?

The location of the closing brace.

foo => { a: 1 }
              ^

foo => Bar[a: 1]
               ^

def comment_targets: () -> Array[Node | Location]

def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?constant: ConstantPathNode | ConstantReadNode | nil, ?elements: Array, ?rest: AssocSplatNode | NoKeywordsParameterNode | nil, ?opening_loc: Location?, ?closing_loc: Location?) -> HashPatternNode

def deconstruct_keys: (Array keys) -> { node_id: Integer, location: Location, constant: ConstantPathNode | ConstantReadNode | nil, elements: Array, rest: AssocSplatNode | NoKeywordsParameterNode | nil, opening_loc: Location?, closing_loc: Location? }

def inspect -> String

def opening: () -> String?

The location of the opening brace.

foo => { a: 1 }
       ^

foo => Bar[a: 1]
          ^

Save the closing_loc location using the given saved source so that it can be retrieved later.

Save the opening_loc location using the given saved source so that it can be retrieved later.

Return a symbol representation of this node type. See Node#type.