Feature #19591
closedAdd symbolize_names to MatchData#named_captures
Description
This feature is a follow-up for MatchData#deconstruct_keys (see https://github.com/ruby/ruby/pull/6216).
Example:
m = /(?<a>.)(?<a>.)/.match("01")  # => #<MatchData "01" a:"0" a:"1">
m.named_captures #=> {"a" => "1"}
m.named_captures(symbolize_names: true) #=> {:a => "1"}
The underlying (C) functionality has been already implemented. The proposal is to expose it via the optional symbolize_keys: true | false keyword argument.
PR is attached: https://github.com/ruby/ruby/pull/6952
        
           Updated by ioquatix (Samuel Williams) over 2 years ago
          Updated by ioquatix (Samuel Williams) over 2 years ago
          
          
        
        
      
      LGTM!
        
           Updated by mame (Yusuke Endoh) over 2 years ago
          Updated by mame (Yusuke Endoh) over 2 years ago
          
          
        
        
      
      Discussed at the dev meeting. @matz (Yukihiro Matsumoto) accepted this, but he also said that the keyword should be symbolize_names, not symbolize_keys, following JSON.parse(..., symbolize_names: true).
        
           Updated by palkan (Vladimir Dementyev) over 2 years ago
          Updated by palkan (Vladimir Dementyev) over 2 years ago
          
          
        
        
      
      - Subject changed from Add symbolize_keys to MatchData#named_captures to Add symbolize_names to MatchData#named_captures
        
           Updated by palkan (Vladimir Dementyev) over 2 years ago
          Updated by palkan (Vladimir Dementyev) over 2 years ago
          
          
        
        
      
      - Description updated (diff)
        
           Updated by palkan (Vladimir Dementyev) over 2 years ago
          Updated by palkan (Vladimir Dementyev) over 2 years ago
          
          
        
        
      
      mame (Yusuke Endoh) wrote in #note-2:
... the keyword should be
symbolize_names, notsymbolize_keys, followingJSON.parse(..., symbolize_names: true).
Updated in the PR
        
           Updated by ioquatix (Samuel Williams) over 2 years ago
          Updated by ioquatix (Samuel Williams) over 2 years ago
          
          
        
        
      
      - Status changed from Open to Closed
Merged, thanks for your contribution to Ruby.