[ruby-core:113192] [Ruby master Feature#19591] Add symbolize_keys to MatchData#named_captures
From:
"ioquatix (Samuel Williams) via ruby-core" <ruby-core@...>
Date:
2023-04-11 23:41:05 UTC
List:
ruby-core #113192
Issue #19591 has been updated by ioquatix (Samuel Williams).
LGTM!
----------------------------------------
Feature #19591: Add symbolize_keys to MatchData#named_captures
https://bugs.ruby-lang.org/issues/19591#change-102730
* Author: palkan (Vladimir Dementyev)
* Status: Open
* Priority: Normal
----------------------------------------
This feature is a follow-up for MatchData#deconstruct_keys (see https://github.com/ruby/ruby/pull/6216).
Example:
```ruby
m = /(?<a>.)(?<a>.)/.match("01") # => #<MatchData "01" a:"0" a:"1">
m.named_captures #=> {"a" => "1"}
m.named_captures(symbolize_keys: 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
--
https://bugs.ruby-lang.org/
______________________________________________
ruby-core mailing list -- [email protected]
To unsubscribe send an email to [email protected]
ruby-core info -- https://ml.ruby-lang.org/mailman3/postorius/lists/ruby-core.ml.ruby-lang.org/