From: Jim Freeze Date: 2005-07-28T22:53:42+09:00 Subject: Re: Combination of two arrays * Claus Spitzer [2005-07-28 20:57:24 +0900]: > I have two arrays. let's call them foo and bar. > foo = [ "a", "b", "c", ... n ] > bar = [ 1 , 2 , 3 , ... m ] > > I am looking for a way to combine them such that the result is something like > > [ [ "a", 1 ], [ "a", 2 ], ... [ "a", m ], [ "b", 1 ], ... [ n, 1 ], > ... [ n, m ] ] irb(main):002:0> foo = [ "a", "b", "c" ] => ["a", "b", "c"] irb(main):003:0> bar = [ 1 , 2 , 3 ] => [1, 2, 3] irb(main):004:0> foo.zip(bar) => [["a", 1], ["b", 2], ["c", 3]] -- Jim Freeze