> You can use inject to merge the hashes, but you probably won't get the
> desired result.

Actually, looks like you get the desired result

a = [{:first => 1, :second => 2}, {:first => 10, :third => 3}]
a.inject(:merge)

On Thu, Dec 9, 2010 at 9:18 AM, Marnen Laibow-Koser
<[email protected]> wrote:
> Priya Buvan wrote in post #967340:
>> Hi All,
>>
>> I'm having unknown number of hashes. How to merge all those hashes into
>> single hash?
>
> Think about the semantics here!  What happens if the same key appears in
> all the hashes? Which value takes priority?
>
>
>>
>> Thanks,
>> Buvana
>
> Best,
> --
> Marnen Laibow-Koser
> http://www.marnen.org
> [email protected]
>
> Sent from my iPhone
>
> --
> Posted via http://www.ruby-forum.com/.
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Ruby on Rails: Talk" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to 
> [email protected].
> For more options, visit this group at 
> http://groups.google.com/group/rubyonrails-talk?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to