From: Luis Parravicini Date: 2007-09-13T04:03:43+09:00 Subject: Re: Merge an array of hashes On 9/12/07, cleaner416 wrote: > For some reason I can't get my head wrapped around this trivial > exercise. I have an array of hashes like so > > a = [ { :some_key => :some_value }, { :another_key > => :another_value } ] > > And I would like to flatten it to single hash in one line so I get > > { :some_key => :some_value, :another_key => :another_value } > > Any suggestions? hash = Hash.new a.each { |h| hash.merge! h } -- Luis Parravicini http://ktulu.com.ar/blog/