> input = [ [1,2,3], [4,5,6], [7,8,9] ] > result = [] > > input.each { |i| do_something_with(result, i) } > > and the result should be > > [ [1,4,7], [2,5,8], [3,6,9] ] > > The question sounds: how is do_something_with implemented? > I have already implemented it but I don't think so it's a state-of-the > art solution ;) Not so state-of-the-art but succint: def do_something_with_result(a, i) i.each_with_index { |e, j| a[j] ? a[j] << e : a << [e] } end