るりまサーチ

最速Rubyリファレンスマニュアル検索!
75件ヒット [1-75件を表示] (0.039秒)

別のキーワード

  1. enumerable max_by
  2. enumerable max
  3. enumerable min_by
  4. enumerable min
  5. enumerable inject

ライブラリ

クラス

モジュール

キーワード

検索結果

Enumerable#lazy -> Enumerator::Lazy (27260.0)

自身を lazy な Enumerator に変換したものを返します。

...自身を lazy な Enumerator に変換したものを返します。

この Enumerator は、以下のメソッドが遅延評価を行う (つまり、配列ではな
くEnumeratorを返す) ように再定義されています。

* map/collect
* flat_map/collect_concat
* select/find_all
*...
...のみlazy)
* cycle (※一貫性のため、ブロックを渡さないケースのみlazy)

以下はピタゴラス数 (a**2 + b**2 = c**2 を満たす自然数 a, b, c の組) を
列挙するプログラムです。

//emlist[例][ruby]{
def pythagorean_triples
(1..Float::INFINITY).lazy.flat...
..._map {|z|
(1..z).flat_map {|x|
(x..z).select {|y|
x**2 + y**2 == z**2
}.map {|y|
[x, y, z]
}
}
}
end
# 最初の10個のピタゴラス数を表示する
p pythagorean_triples.take(10).force # takeはlazyなので、forceが必要です
p pythagorean_tripl...

Enumerator::Lazy#select {|item| ... } -> Enumerator::Lazy (18294.0)

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

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

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

//emlist[例][ruby]{
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 Enumerable#select...

Enumerator::Lazy (18094.0)

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

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

動作は通常の Enumerator と同じですが、以下のメソッドが遅延評価を行う
(つまり、配列ではなく Enumerator を返す) ように再定義されています。

* map/collect...
... select/find_all
* reject
* grep
* take, take_while
* drop, drop_while
* slice_before, slice_after, slice_when
* chunk
* 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)
# LTSV (http://ltsv.org/) 形式のログ...
..._map/collect_concat
* select/find_all
* reject
* grep, grep_v
* take, take_while
* drop, drop_while
* slice_before, slice_after, slice_when
* chunk
* 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)
# LTSV (http:...
...t_concat
* 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)
# LT...
...lter_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メソッ...
...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
オブジェクトは、Enumerable#lazy...

Enumerator::Lazy#filter {|item| ... } -> Enumerator::Lazy (3194.0)

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

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

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

//emlist[例][ruby]{
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 Enumerable#select...

Enumerator::Lazy#find_all {|item| ... } -> Enumerator::Lazy (3194.0)

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

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

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

//emlist[例][ruby]{
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 Enumerable#select...

絞り込み条件を変える

NEWS for Ruby 2.6.0 (108.0)

NEWS for Ruby 2.6.0 このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。

...と値に変換できるようになりました。 15143
* 別名
* Array#filter が Array#select の別名として追加されました。 13784
* Array#filter! が Array#select! の別名として追加されました。 13784

* Binding
* 新規メソッド
* Binding...
...追加 13969

* Enumerable
* 新規メソッド
* Enumerable#chain はレシーバと引数のそれぞれの要素を順番にイテレートする
Enumerator::Chain オブジェクトを返します。 15144
* 変更されたメソッド
* Enumerable#to_h はブロ...
...n
* 1個の Enumerator で複数の Enumerable の連鎖を表現する新しいクラスです。
Enumerable
#chain や Enumerator#+ で生成されます。

* Enumerator::Lazy
* 別名
* Enumerator::Lazy#filter が Enumerator::Lazy#select の別名として追加されまし...

NEWS for Ruby 2.2.0 (78.0)

NEWS for Ruby 2.2.0 このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。

...* 追加: Binding#receiver

* Dir
* 追加: Dir#fileno

* Enumerable
* 追加: Enumerable#slice_after
* 追加: Enumerable#slice_when
* 拡張: Enumerable#min, Enumerable#min_by, Enumerable#max, Enumerable#max_by
は複数の値を返すためのオプションをサ...
...hout_gvl family
* TRAP_BEG -> rb_thread_call_without_gvl family
* TRAP_END -> rb_thread_call_without_gvl family
* rb_thread_select -> rb_thread_fd_select
* struct rb_exec_arg : internal type. no replacement.
* rb_exec : internal function. no replacement.
* rb_exec_arg_addopt...
...した。9634
* メジャーGCにインクリメンタルマーキングを導入しました。10137
* malloc によって起きた GC で lazy sweep を有効にしました。

* VM
* Hash#[] と Hash#[]= で変更不可能な文字列リテラルを使用するようにしまし...

NEWS for Ruby 2.3.0 (60.0)

NEWS for Ruby 2.3.0 このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。

...* Encoding
* Encoding::IBM037 (alias ebcdic-cp-us; dummy) を追加

* Enumerable
* Enumerable#grep_v を追加
11049
* Enumerable#chunk_while
10769

* Enumerator::Lazy
* Enumerator::Lazy#grep_v を追加
11773

* File
* File.mkfifo
11536
* O_...
...read#name, Thread#name= を追加
11251

=== 組み込みクラスの互換性 (機能追加とバグ修正を除く)

* Array
* Array#select!, Array#keep_if, Array#reject!, Array#delete_if
ブロックが評価される度にレシーバーの配列をすぐに変更しないよ...
...
互換性のないエンコーディングであっても例外が発生しなくなりました。
11801

* Enumerable
* Enumerable#chunk と Enumerable#slice_before は初期状態を引数として受け取らなくなりました。
状態の管理にはローカル...