diff --git a/struct.c b/struct.c index b85f7c035e..4ebf6aa3fa 100644 --- a/struct.c +++ b/struct.c @@ -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