Combine 3 hash into one

Hi
I am trying to marge 3 hash : hash1["errors"] ,hash2["errors"],hash3

so what i am doing this

p hash1["errors"].zip(hash2["errors"],hash3).flatten.compact

Which works fine when hash1["errors"] has at least one value

but problem is :

if hash1["errors"] (which is the first one in marge)
does not have any Value, then whole marge hash values show nill

output .

[]

Whats the best procedure to marge 3 hash

Thank

···

--
Posted via http://www.ruby-forum.com/.

Zipping and merging are not the same. Try #merge method.

···

On Saturday, January 26, 2013 1:04:55 PM UTC-5, robert lengu wrote:

Hi
I am trying to marge 3 hash : hash1["errors"] ,hash2["errors"],hash3

so what i am doing this

p hash1["errors"].zip(hash2["errors"],hash3).flatten.compact

Which works fine when hash1["errors"] has at least one value

but problem is :

if hash1["errors"] (which is the first one in marge)
does not have any Value, then whole marge hash values show nill

output .

hash1.merge(hash2).merge(hash3)

doesn't work?

···

On Sat, Jan 26, 2013 at 12:04 PM, robert lengu <lists@ruby-forum.com> wrote:

I am trying to marge 3 hash : hash1["errors"] ,hash2["errors"],hash3