Method: Hash#rekey!
- Defined in:
- lib/core/facets/hash/rekey.rb
#rekey!(key_map = nil, &block) ⇒ Object
Synonym for Hash#rekey, but modifies the receiver in place (and returns it).
foo = { :name=>'Gavin', :wife=>:Lisa }
foo.rekey!{ |k| k.to_s } #=> { "name"=>"Gavin", "wife"=>:Lisa }
foo #=> { "name"=>"Gavin", "wife"=>:Lisa }
CREDIT: Trans, Gavin Kistner
77 78 79 |
# File 'lib/core/facets/hash/rekey.rb', line 77 def rekey!(key_map=nil, &block) replace(rekey(key_map, &block)) end |