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