From: ChrisH Date: 2006-03-29T17:28:42+09:00 Subject: Re: two arrays problem (although different from the other two arrays) Kev Jackson wrote: > I have a bunch of japanese encoded words in Kanji and Hirigana (I > think). Each set is broken into two pieces, name and type, which can be > combined to produce many more words, so this looks like a classic > 'iterate over two arrays problem' > > This is what I have, I tried messing with inject and I couldn't get the > desired output. If anyone wants to golf it I'd like to learn what I > should be doing instead > > corp_data_1.each do |cd1| > corp_data_2.each do |cd2| > rd << cd1 + cd2 > end > end > > Thanks > Kev Not necessarily better but: rd = corp_data_1.map{|cd1| corp_data_2.map{|cd2| cd1 + cd2}} cheers