From: Pen Ttt on
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
how to get it ?
--
Posted via http://www.ruby-forum.com/.

From: Brian Candler on
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/.