On 20.08.2008 19:34, Brian Ross wrote: > 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? Folks, thanks for leaving the #inject solution to me. :-) map = hash.inject({}) do |h,(k,v)| h[k.upcase] = v h end Cheers robert