From: Phrogz Date: 2006-07-21T05:40:07+09:00 Subject: Re: how to split an array in sub arrays of the same length Paolo Bacchilega wrote: > Is there a way to split an array in sub arrays of the same length, that Stolen from the facets[1] extensions for Arrays[2]: class Array def each_slice(n=nil, &yld) n = yld.arity.abs unless n i=0 while i < self.length yld.call(*self.slice(i,n)) i+=n end end end [1] http://facets.rubyforge.org/ [2] http://facets.rubyforge.org/api/core/classes/Array.html#M000163