Method: Hash#update_keys

Defined in:
lib/core/facets/hash/update_keys.rb

#update_keysObject

Iterate over hash updating just the keys.

h = {:a=>1, :b=>2}
h.update_keys{ |k| "#{k}!" }
h  #=> { "a!"=>1, "b!"=>2 }


12
13
14
15
16
17
18
# File 'lib/core/facets/hash/update_keys.rb', line 12

def update_keys #:yield:
  if block_given?
    keys.each { |old_key| store(yield(old_key), delete(old_key)) }
  else
    to_enum(:update_keys)
  end
end