るりまサーチ

最速Rubyリファレンスマニュアル検索!
10件ヒット [1-10件を表示] (0.027秒)
トップページ > クエリ:step[x] > クエリ:take[x] > クエリ:Lazy[x] > クエリ:filter_map[x]

別のキーワード

  1. _builtin lazy
  2. lazy slice_before
  3. lazy take_while
  4. lazy zip
  5. lazy to_enum

ライブラリ

クラス

検索結果

Enumerator::Lazy#filter_map {|item| ... } -> Enumerator::Lazy (21306.0)

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

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

@raise ArgumentError ブロックを指定しなかった場合に発生します。

//emlist[例][ruby]{
1.step.lazy.filter_map { |n| n * 2 if n.even? }
# => #<Enumerator::Lazy: #<Enumerator::Lazy: (1.step)>...
...:filter_map>

1.step.lazy.filter_map { |n| n * 2 if n.even? }.take(10).force
# => [4, 8, 12, 16, 20, 24, 28, 32, 36, 40]
//}

@see Enumerable#filter_map...

Enumerator::Lazy (18072.0)

map や select などのメソッドの遅延評価版を提供するためのクラス。

...t
* filter_map
* select/find_all
* reject
* grep, grep_v
* take, take_while
* drop, drop_while
* slice_before, slice_after, slice_when
* chunk, chunk_while
* uniq
* zip (※互換性のため、ブロックを渡さないケースのみlazy)

Lazy
オブジェクトは、Enumerable#lazy...
...ドによって生成されます。

Lazy
から値を取り出すには、Enumerator::Lazy#force または
Enumerable#first を呼びます。

//emlist[例][ruby]{
# 二乗して偶数になるような整数を、小さい方から5個表示する
p 1.step.lazy.select{|n| (n**2).even?}.first(5)
#...
...のログファイルから検索を行う
# Enumerator::Lazy#map は配列ではなく Enumerator を返すため、
# 巨大な配列を確保しようとしてメモリを使い切ったりはしない
open("log.txt"){|f|
f.each_line.lazy.map{|line|
Hash[line.split(/\t/).map{|s| s.split(/:/...
.../collect_concat
* filter_map
* select/find_all
* reject
* grep, grep_v
* take, take_while
* drop, drop_while
* slice_before, slice_after, slice_when
* chunk, chunk_while
* uniq
* compact
* zip (※互換性のため、ブロックを渡さないケースのみlazy)

Lazy
オブジェクト...