2005/8/29, SHIGETOMI, Takuhiko <tshiget1 / gw.nsw.co.jp>:
> dear guys,
> 
> i am seeking a smart way to do ...
> 
>    [ 1, 2, 3, 4, 5, 6, ... ]  =>  [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ], ... ]
> 
> especialy, the way hopefully will work safety when the source array's
> size is odd or zero.

This is a pretty much straightforward implementation:

>> res=[]; 0.step(a.length - 1,2) {|i| res << [a[i],a[i+1]]}; res
=> [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9]]

Kind regards

robert