[#81999] [Ruby trunk Bug#13737] "can't modify frozen String" when installing bundled gems — ko1@...
Issue #13737 has been updated by ko1 (Koichi Sasada).
4 messages
2017/07/11
[#82005] [Ruby trunk Bug#13737] "can't modify frozen String" when installing bundled gems — nobu@...
Issue #13737 has been updated by nobu (Nobuyoshi Nakada).
3 messages
2017/07/12
[#82102] Re: register_fstring_tainted:FL_TEST_RAW(str, RSTRING_FSTR) — Eric Wong <normalperson@...>
Koichi Sasada <ko1@atdot.net> wrote:
4 messages
2017/07/18
[#82151] [Ruby trunk Feature#13637] [PATCH] tool/runruby.rb: test with smallest possible machine stack — Rei.Odaira@...
Issue #13637 has been updated by ReiOdaira (Rei Odaira).
3 messages
2017/07/24
[ruby-core:82044] [Ruby trunk Feature#13583] Adding `Hash#transform_keys` method
From:
matz@...
Date:
2017-07-14 05:33:58 UTC
List:
ruby-core #82044
Issue #13583 has been updated by matz (Yukihiro Matsumoto).
Looks good to me.
Matz.
----------------------------------------
Feature #13583: Adding `Hash#transform_keys` method
https://bugs.ruby-lang.org/issues/13583#change-65770
* Author: graywolf (Gray Wolf)
* Status: Open
* Priority: Normal
* Assignee:
* Target version:
----------------------------------------
In 2.4, new useful method `Hash#transform_values` was added. I would like to propose also adding matching method `Hash#transform_keys`.
```ruby
{a: 1, b: 2}.transform_keys { |k| k.to_s }
=> {"a"=>1, "b"=>2}
```
What needs to be considered is what to do in case of two keys mapping to the same new key
```ruby
{ a: 1, b: 2 }.transform_keys {|_| :same_key } # what should happen?
```
I think using `Hash[]` as model behaviour is a good idea.
```ruby
Hash[{ a: 1, b: 2 }.map { |key, value| [:s, value] }]
=> {:s=>2}
```
it's also how `Hash#transform_keys` works in rails (afaict).
This is a follow up feature request to #9970, which seems to be stalled. If the behaviour can be agreed upon, I can try putting together a patch (if no one else wants to step up).
--
https://bugs.ruby-lang.org/
Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>