Project

General

Profile

Actions

Feature #15917

closed

Pattern matching for Struct

Added by marcandre (Marc-Andre Lafortune) almost 5 years ago. Updated over 4 years ago.

Status:
Closed
Target version:
-
[ruby-core:93074]

Description

Structs respond to deconstruct, not to deconstruct_keys. Shouldn't we also implement it?

A = Struct.new(:foo, :bar)

case A.new(1, 2)
in foo: 1, **rest
  p "match"
else
  p "no match"
end
# => "no match", should be "match"
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0