diff options
-rw-r--r-- | struct.c | 2 | ||||
-rw-r--r-- | test/ruby/test_pattern_matching.rb | 12 |
2 files changed, 14 insertions, 0 deletions
@@ -1345,6 +1345,8 @@ InitVM_Struct(void) rb_define_method(rb_cStruct, "members", rb_struct_members_m, 0); rb_define_method(rb_cStruct, "dig", rb_struct_dig, -1); + + rb_define_method(rb_cStruct, "deconstruct", rb_struct_to_a, 0); } #undef rb_intern diff --git a/test/ruby/test_pattern_matching.rb b/test/ruby/test_pattern_matching.rb index b0d8e4778b..9153297d39 100644 --- a/test/ruby/test_pattern_matching.rb +++ b/test/ruby/test_pattern_matching.rb @@ -1072,4 +1072,16 @@ END end end end + + ################################################################ + + def test_struct + assert_block do + s = Struct.new(:a, :b) + case s[0, 1] + in 0, 1 + true + end + end + end end |