B
Brian Ross
[Note: parts of this message were removed to make it a legal post.]
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
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