Feature #15917
closed
Pattern matching for Struct
Added by marcandre (Marc-Andre Lafortune) over 7 years ago.
Updated almost 7 years ago.
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"
- Tracker changed from Bug to Feature
- Backport deleted (
2.4: UNKNOWN, 2.5: UNKNOWN, 2.6: UNKNOWN)
- Assignee set to ktsj (Kazuki Tsujimoto)
- Status changed from Open to Closed
Also available in: PDF
Atom