[ruby-core:93074] [Ruby trunk Bug#15917] Pattern matching for Struct

From: ruby-core@...
Date: 2019-06-12 13:41:00 UTC
List: ruby-core #93074
Issue #15917 has been reported by marcandre (Marc-Andre Lafortune).

----------------------------------------
Bug #15917: Pattern matching for Struct
https://bugs.ruby-lang.org/issues/15917

* Author: marcandre (Marc-Andre Lafortune)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
* ruby -v: 
* Backport: 2.4: UNKNOWN, 2.5: UNKNOWN, 2.6: UNKNOWN
----------------------------------------
`Struct`s 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"
```




-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:[email protected]?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>

In This Thread

Prev Next