instance method Enumerator::Lazy#chunk

chunk {|elt| ... } -> Enumerator::Lazy[permalink][rdoc][edit]
chunk(initial_state) {|elt, state| ... } -> Enumerator::Lazy

Enumerable#chunk と同じですが、配列ではなく Enumerator::Lazy を返します。



1.step.lazy.chunk{ |n| n % 3 == 0 }
# => #<Enumerator::Lazy: #<Enumerator: #<Enumerator::Generator:0x007f8bf18118f0>:each>>

1.step.lazy.chunk{ |n| n % 3 == 0 }.take(5).force
# => [[false, [1, 2]], [true, [3]], [false, [4, 5]], [true, [6]], [false, [7, 8]]]

[SEE_ALSO] Enumerable#chunk