On Dec 9, 2010, at 7:09 AM, Vladimir Rybas wrote:
array_of_hashes = [{:first => 1, :second => 2}, {:first =>
10, :third => 3}]
Hash[*array_of_hashes.collect{|hash| hash.collect{|key,value|
[key,value].flatten}.flatten}.flatten]
=> {:first=>10, :second=>2, :third=>3}
Simpler, but same idea.
irb> Hash[*array_of_hashes.map{|_|_.to_a}.flatten]
=> {:second=>2, :third=>3, :first=>10}
-Rob
Rob Biedenharn
[email protected] http://AgileConsultingLLC.com/
[email protected] http://GaslightSoftware.com/
On Thu, Dec 9, 2010 at 10:26 AM, Priya Buvan <[email protected]>
wrote:
@Michael: yes its in array..
@Marnen: If there is more than one key with same name, obviously
it'll
be override. This is fine.
Anyway i'm trying to fetch the result separately. I'll reply with
latest
updated soon.
Thanks,
Buvana
--
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.