From: Brian Candler Date: 2010-05-02T17:36:40+09:00 Subject: Re: how can i get that kind of transpose? Pen Ttt wrote: > there is text1 > 1,2,3,4 > 1,2,3 > 1,2 > 1,2,3,4,5 > what i want to get is text2: > 1,1,1,1 > 2,2,2,2 > 3,3, 3 > 4, 4 > 5 Is this what you want? >> a = [[1,2,3,4,nil],[1,2,3,nil,nil],[1,2,nil,nil,nil],[1,2,3,4,5]] => [[1, 2, 3, 4, nil], [1, 2, 3, nil, nil], [1, 2, nil, nil, nil], [1, 2, 3, 4, 5]] >> a.transpose => [[1, 1, 1, 1], [2, 2, 2, 2], [3, 3, nil, 3], [4, nil, nil, 4], [nil, nil, nil, 5]] -- Posted via http://www.ruby-forum.com/.