From: wolf@... Date: 2017-05-17T22:37:13+00:00 Subject: [ruby-core:81220] [Ruby trunk Feature#9970] Add `Hash#map_keys` and `Hash#map_values` Issue #9970 has been updated by graywolf (Gray Wolf). What's the status on this? In #12512, only Hash#transform_values was added, should I bother making patch adding Hash#transform_keys (and maybe Hash#transform_pairs)? Or is this (#9970) still in the process based on last comment from matz ("We will take care [of it].")? W. ---------------------------------------- Feature #9970: Add `Hash#map_keys` and `Hash#map_values` https://bugs.ruby-lang.org/issues/9970#change-64874 * Author: seantheprogrammer (Sean Griffin) * Status: Open * Priority: Normal * Assignee: nobu (Nobuyoshi Nakada) * 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/ Unsubscribe: