From: Brian Ross
Date: 2008-08-21T04:48:52+09:00
Subject: Re: Iterating through a hash
------=_Part_42764_11360350.1219261948776
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
On Wed, Aug 20, 2008 at 2:32 PM, Martin DeMello wrote:
> without the ugly "h" at the end :) :
>
> map = hash.inject({}) {|h, (k,v)| h.update({k.upcase => v})}
>
Thanks everyone! Using Martin's example, how would I then use upcase for an
array of hashes?
I'd imagine it would be
this_array.collect do |hash|
@map = {}
hash.each_pair do |k,v|
@map[k.upcase] = v
end
end
but while the @map gives me the scope to see it outside of the block, it
looks like only the first hash within the array is passed through.
Brian
------=_Part_42764_11360350.1219261948776--