Ruby 2.7.0 リファレンスマニュアル > ライブラリ一覧 > 組み込みライブラリ > Enumerator::Lazyクラス > slice_after

instance method Enumerator::Lazy#slice_after

slice_after(pattern) -> Enumerator::Lazy[permalink][rdoc]
slice_after {|elt| bool } -> Enumerator::Lazy

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



1.step.lazy.slice_after { |e| e % 3 == 0 }
# => #<Enumerator::Lazy: #<Enumerator: #<Enumerator::Generator:0x007fd73980e6f8>:each>>

1.step.lazy.slice_after { |e| e % 3 == 0 }.take(5).force
# => [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12], [13, 14, 15]]

[SEE_ALSO] Enumerable#slice_after