Issue #17315 has been updated by sawa (Tsuyoshi Sawada).


marcandre (Marc-Andre Lafortune) wrote in #note-2:
> I'll reopen this, as you are asking for a mutating version of `to_h`.

It might be strange to have `transform!` as the destructive counterpart to `to_h`. Perhaps, the naming should be `to_h!`?

----------------------------------------
Feature #17315: Hash #transform
https://bugs.ruby-lang.org/issues/17315#change-88422

* Author: dsisnero (Dominic Sisneros)
* Status: Open
* Priority: Normal
----------------------------------------
Add new methods to `transform` or `transform!` both the keys and the values of a hash.
#7793 

```ruby
h = {'name' => 'dominic ', 'email' => 'dominic.mail.com '}
h.transform!{|k,v| [k.to_sym, v.strip]}
h # => {name: 'dominic', email: 'dominic.mail.com'}
```



-- 
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>