Skip to content
On this page
class · Ruby 4.0

Prism::HashPatternNode

< Prism::Node 16 instance methods 2 class methods

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 }
       ^^^^^^^^^^^^^^

Class methods 2

Instance methods 16

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 }
                   ^^^^^