# DEPRECATE. THIS IS INCLUDED IN ENUMERABLE NOW. class Array # Iterates over +n+ elements at a time. If +n+ is # not given then the arity of the block determines the # slicing quantity. # # require 'facet/array/each_slice' # # [1, 2, 3, 4].each_slice(2){ |a,b| ... } # # Enumerable#each_slice offers the same functionality # but this is a more efficient implementation specifically # for the 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 alias_method( :each_by, :each_slice ) end