[ruby-core:115592] [Ruby master Feature#20040] Make Hash respond do deconstruct to allow matchting key/value pairs
 
            
            
            
            
                5 Dec
                
                    2023
                
            
            
                5 Dec
                
                '23
                
            
            
            
        
    
                10:24 a.m.
            
        Issue #20040 has been reported by jochen@seeber.me (Jochen Seeber). ---------------------------------------- Feature #20040: Make Hash respond do deconstruct to allow matchting key/value pairs https://bugs.ruby-lang.org/issues/20040 * Author: jochen@seeber.me (Jochen Seeber) * Status: Open * Priority: Normal ---------------------------------------- It would be nice to allow pattern matching to work on key/value pairs of a Hash to e.g. find the first entry, or entries where the key is not known. Example: ``` class Hash; def deconstruct = to_a; end {a: 1, b: 2} => [[k, v], *] puts "k=#{k}" # :a puts "v=#{v}" # 1 {a: 1, b: 2} => [*, [k, 2], *] puts "k=#{k}" # :b ``` -- https://bugs.ruby-lang.org/
        696
        
      
          Age (days ago)
        
      
        696
        
    
          Last active (days ago)
        
        
        
        0 comments
    
    
        
        1 participants
    
    
    
    
    
    
    
    
    participants (1)
- 
                 jochen@seeber.me (Jochen Seeber) jochen@seeber.me (Jochen Seeber)