On Aug 28, 2005, at 8:50 PM, SHIGETOMI, Takuhiko wrote:

> 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.

Pretty hackish but:

irb(main):001:0> arr = [ 1, 2, 3, 4, 5, 6]
=> [1, 2, 3, 4, 5, 6]
irb(main):011:0> arr << nil unless arr.size % 2 == 0
=> nil
irb(main):012:0> Hash[*arr].to_a.sort
=> [[1, 2], [3, 4], [5, 6]]

I was just playing around.  I like David's in_slices() method much  
better.

James Edward Gray II