Represents a hash key/value pair.

{ a => b }
  ^^^^^^
Attributes

key

Read

The key of the association. This can be any [non-void expression](github.com/ruby/prism/blob/main/docs/parsing_rules.md#non-void-expression).

{ a: b }
  ^

{ foo => bar }
  ^^^

{ def a; end => 1 }
  ^^^^^^^^^^
Read

The value of the association, if present. This can be any [non-void expression](github.com/ruby/prism/blob/main/docs/parsing_rules.md#non-void-expression).

{ foo => bar }
         ^^^

{ x: 1 }
     ^
Class Methods

Initialize a new AssocNode 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[nil | Node]

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

def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?key: Prism::node, ?value: Prism::node, ?operator_loc: Location?) -> AssocNode

An alias for child_nodes

def deconstruct_keys: (Array keys) -> { node_id: Integer, location: Location, key: Prism::node, value: Prism::node, operator_loc: Location? }

def inspect -> String

def operator: () -> String?

The location of the ‘=>` operator, if present.

{ foo => bar }
      ^^

Save the operator_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`.