From: Robert Klemme Date: 2005-10-13T18:46:54+09:00 Subject: Re: array1 + array2 newb question Kroeger, Simon (ext) wrote: >> From: Robert Klemme [mailto:bob.news@gmx.net] >> Since there hasn't been an #inject solution so far... :-) > > hmm, is the gateway broken again? > > a1.inject([]){|s, x| s + a2.map {|y| [x, y]}} > > (posted 1 hour ago) No, it's here. Can't tell though whether I just overlooked it or whether the posting arrived here after I wrote mine. And note that your version has the disadvantage that you copy s all the time. Using concat is more efficient. Even if you use that there's an intermediate array per x value that is dropped again. That's why my solution just appends two element arrays to the collecting array. :-) Kind regards robert