Sha256: 3a541e555424daf5226bff628f592de6d70a5724ffe26f0fdc5390aa46b1cf0f
Contents?: true
Size: 624 Bytes
Versions: 10
Compression:
Stored size: 624 Bytes
Contents
# 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
Version data entries
10 entries across 10 versions & 1 rubygems