[#84280] [Ruby trunk Bug#14181] hangs or deadlocks from waitpid, threads, and trapping SIGCHLD — nobu@...
Issue #14181 has been updated by nobu (Nobuyoshi Nakada).
3 messages
2017/12/15
[#84398] [Ruby trunk Bug#14220] WEBrick changes - failures on MSWIN, MinGW — Greg.mpls@...
Issue #14220 has been reported by MSP-Greg (Greg L).
3 messages
2017/12/22
[#84472] Re: [ruby-dev:50394] [Ruby trunk Bug#14240] warn four special variables: $; $, $/ $\ — Eric Wong <normalperson@...>
Shouldn't English posts be on ruby-core instead of ruby-dev?
3 messages
2017/12/26
[ruby-core:84172] [Ruby trunk Feature#13583][Closed] Adding `Hash#transform_keys` method
From:
ruby-core@...
Date:
2017-12-11 22:07:07 UTC
List:
ruby-core #84172
Issue #13583 has been updated by marcandre (Marc-Andre Lafortune).
Status changed from Open to Closed
Nevermind, I just remembered that ActiveSupport also defines `transform_keys!`, so best match its behavior.
----------------------------------------
Feature #13583: Adding `Hash#transform_keys` method
https://bugs.ruby-lang.org/issues/13583#change-68282
* Author: graywolf (Gray Wolf)
* Status: Closed
* Priority: Normal
* Assignee: matz (Yukihiro Matsumoto)
* 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:[email protected]?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>