[#62904] [ruby-trunk - Feature #9894] [Open] [RFC] README.EXT: document rb_gc_register_mark_object — normalperson@...
Issue #9894 has been reported by Eric Wong.
3 messages
2014/06/02
[#63321] [ANN] ElixirConf 2014 - Don't Miss Jos辿 Valim and Dave Thomas — Jim Freeze <jimfreeze@...>
Just a few more weeks until ElixirConf 2014!
6 messages
2014/06/24
[ruby-core:63272] [ruby-trunk - Feature #9970] Add `Hash#map_keys` and `Hash#map_values`
From:
matthew@...
Date:
2014-06-21 23:49:00 UTC
List:
ruby-core #63272
Issue #9970 has been updated by Matthew Kerwin.
Duplicate of #7793 ?
--
Matthew Kerwin
http://matthew.kerwin.net.au/
----------------------------------------
Feature #9970: Add `Hash#map_keys` and `Hash#map_values`
https://bugs.ruby-lang.org/issues/9970#change-47318
* Author: Sean Griffin
* Status: Open
* Priority: Normal
* Assignee:
* Category:
* Target version:
----------------------------------------
These methods simplify two common patterns when working with hashes, and transforming 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)
--
https://bugs.ruby-lang.org/