From: Laza Date: 2005-12-01T10:07:31+09:00 Subject: Re: Help constructing interesting hash? Firstly, you can use Array#zip instead of each_with_index: h = {} [1,2,3].zip([:a, :b, :c]){|key, value| h[key] = value } h => {1=>:a, 2=>:b, 3=>:c} Secondly, here is the answer h = {} [1, 2, 2].zip([:a, :b, :c]){|key, value| h[key] ||= []; # if key not defined, make it [] h[key]< {1=>[:a], 2=>[:b, :c]} You can also combine the two lines in (h[key] ||= []) << value