Peter Szinek wrote: > Hello, > > 1) > I would like to create an array of n empty arrays, i.e. > > [ [], [], ... n-3 []'s, [] ] > > So that the inner arrays are different objects. > > Array.new(n,[]) does not help since the created arrays are not different > objects. > > Is there an idiomatic way to accomplish this? a = (0..3).collect{[]} # => [[], [], [], []] a[0][0] = 1 a # => [[1], [], [], []] > > 2) Is there an idiomatic way to do this (in a generic way, of course): > > some_func( > [1,2,3] > [4,5,6] > [7,8,9] ) > > => [ [1,4,7], [2,5,8], [3,6,9] ] [1,2,3].zip([4,5,6],[7,8,9]) # => [[1,4,7], [2,5,8], [3,6,9]] -- Alex