[ruby-core:93985] [Ruby master Feature#15917] Pattern matching for Struct
From:
ko1@...
Date:
2019-07-29 08:12:01 UTC
List:
ruby-core #93985
Issue #15917 has been updated by ko1 (Koichi Sasada). Assignee set to ktsj (Kazuki Tsujimoto) ---------------------------------------- Feature #15917: Pattern matching for Struct https://bugs.ruby-lang.org/issues/15917#change-80179 * Author: marcandre (Marc-Andre Lafortune) * Status: Open * Priority: Normal * Assignee: ktsj (Kazuki Tsujimoto) * Target version: ---------------------------------------- `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:ruby-core-request@ruby-lang.org?subject=unsubscribe> <http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>