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

instance method Enumerator::Lazy#find_all

select {|item| ... } -> Enumerator::Lazy[permalink][rdoc]
find_all {|item| ... } -> Enumerator::Lazy

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

[EXCEPTION] ArgumentError:
ブロックを指定しなかった場合に発生します。


1.step.lazy.find_all { |i| i.even? }
# => #<Enumerator::Lazy: #<Enumerator::Lazy: #<Enumerator: 1:step>>:find_all>

1.step.lazy.select { |i| i.even? }.take(10).force
# => [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]

[SEE_ALSO] Enumerable#select