From: Brian Ross
Date: 2008-08-21T02:34:32+09:00
Subject: Iterating through a hash
------=_Part_40773_16822391.1219253887680
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
How can I iterate through a hash so that each key is modified and saved into
a new hash?
# Beginning of code
hash = {"name"=>"greg", "job"=>"boring", "hair"=>"plenty"}
p hash
map = hash.each_key do |key|
key.upcase
end
p map
# End of code
I'd imagine that this would return map as a new hash with the keys modified.
Is there anything like collect! for hashes?
Brian
------=_Part_40773_16822391.1219253887680--