mirror of
				https://github.com/ruby/ruby.git
				synced 2022-11-09 12:17:21 -05:00 
			
		
		
		
	Define Struct#deconstruct
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67587 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
		
							parent
							
								
									9738f96fcf
								
							
						
					
					
						commit
						9c9db64d7e
					
				
					 2 changed files with 14 additions and 0 deletions
				
			
		
							
								
								
									
										2
									
								
								struct.c
									
										
									
									
									
								
							
							
						
						
									
										2
									
								
								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
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue