[#66126] Creation/Conversion methods/functions table for Ruby types — SASADA Koichi <ko1@...>
Hi,
5 messages
2014/11/07
[#66289] Re: Creation/Conversion methods/functions table for Ruby types
— Eric Wong <normalperson@...>
2014/11/14
SASADA Koichi <[email protected]> wrote:
[#66293] Re: Creation/Conversion methods/functions table for Ruby types
— SASADA Koichi <ko1@...>
2014/11/14
On 2014/11/15 7:44, Eric Wong wrote:
[#66248] [ruby-trunk - Feature #10423] [PATCH] opt_str_lit*: avoid literal string allocations — normalperson@...
Issue #10423 has been updated by Eric Wong.
3 messages
2014/11/13
[#66595] [ruby-trunk - Bug #10557] [Open] Block not given when the argument is a string — bartosz@...
Issue #10557 has been reported by Bartosz Kopinski.
3 messages
2014/11/30
[ruby-core:66561] [ruby-trunk - Feature #9970] Add `Hash#map_keys` and `Hash#map_values`
From:
duerst@...
Date:
2014-11-29 03:04:04 UTC
List:
ruby-core #66561
Issue #9970 has been updated by Martin D=C3=BCrst.
Related to Feature #10552: [PATCH] Add Enumerable#frequencies and Enumerabl=
e#relative_frequencies added
----------------------------------------
Feature #9970: Add `Hash#map_keys` and `Hash#map_values`
https://bugs.ruby-lang.org/issues/9970#change-50174
* Author: Sean Griffin
* Status: Open
* Priority: Normal
* Assignee:=20
* Category:=20
* Target version:=20
----------------------------------------
These methods simplify two common patterns when working with hashes, and tr=
ansforming the data.
Without `map_keys`:
`Hash[{ a: 1, b: 2 }.map { |key, value| [key.to_s, value] }]`
With `map_keys`:
`{ a: 1, b: 2 }.map_keys(&:to_s)`
Without `map_values`:
`Hash[{ a: '1', b: '2' }.map { |key, value| [key, value.to_i] }]`
With `map_values`:
`{ a: '1', b: '2' }.map_values(&:to_i)`
The patch, with tests, is attached.
---Files--------------------------------
hash-map-keys-and-map-values.diff (5.79 KB)
--=20
https://bugs.ruby-lang.org/