るりまサーチ

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

別のキーワード

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

ライブラリ

クラス

モジュール

キーワード

検索結果

<< 1 2 3 ... > >>

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

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

...数を表示する
p pythagorean_triples.take(10).force # takeはlazyなので、forceが必要です
p pythagorean_triples.first(10) # firstはeagerです
# 100より小さいピタゴラス数を表示する
p pythagorean_triples.take_while { |*, z| z < 100 }.force
//}

@see Enumerator::Lazy...

Enumerator::Lazy#force(*args) -> [object] (18113.0)

全ての要素を含む配列を返します。Lazy から実際に値を取り出すのに使います。

...の要素を含む配列を返します。Lazy から実際に値を取り出すのに使います。

Enumerable
#to_a のエイリアスです。

//emlist[例][ruby]{
1.step.lazy.take(10).force
# => [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]

1.step.lazy.take(10).to_a
# => [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
//}...

NEWS for Ruby 3.1.0 (54.0)

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

...> []
//}

* Enumerable
* 新規メソッド
* Enumerable#compactが追加されました。 17312
* Enumerable#tallyがカウント集計用のハッシュオブジェクトを任意で渡せるようになりました。 17744
* Enumerable#each_consとEnumerable#each_slice...
...がレシーバを返すようになりました。 https://github.com/ruby/ruby/pull/1509

//emlist[Enumerable#each_cons Enumerable#each_slice][ruby]{
[1, 2, 3].each_cons(2){}
# 3.0 => nil
# 3.1 => [1, 2, 3]

[1, 2, 3].each_slice(2){}
# 3.0 => nil
# 3.1 => [1, 2, 3]
//}

* Enumerator::Lazy
*...
...るかもしれません。 17866

== C API の更新

* ドキュメント化されました。 https://github.com/ruby/ruby/pull/4815
* rb_gc_force_recycleは非推奨で、no-op関数に変更されました。 18290

== 実装の改善

* クラス変数の読み込みにインラインキ...

NEWS for Ruby 2.7.0 (48.0)

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

...目すべきもののみ)

* Array
* 新規メソッド
* Array#intersectionが追加されました。 16155
* Array#minmaxがEnumerable#minmaxより高速な実装として追加されました。 15929

* Comparable
* 変更されたメソッド
* Comparable#clampが...
...931

* Enumerable
* 新規メソッド
* Enumerable#filter_mapが追加されました。 15323
* Enumerable#tallyが追加されました。 11076
//emlist[Enumerable#filter_map][ruby]{
[1, 2, 3].filter_map {|x| x.odd? ? x.to_s : nil } #=> ["1", "3"]
//}
//emlist[Enumerable#tally]...
...FOO!?", "BAR!?", "BAZ!?"]
//}
//emlist[Enumerator::Lazy#with_index][ruby]{
("a"..).lazy.with_index(1) { |it, index| puts "#{index}:#{it}" }.take(3).force
# => 1:a
# 2:b
# 3:c
//}

* Fiber
* 新規メソッド
* Fiber#raiseメソッドが追加され、Fiber#resumeのように...

Enumerator::Lazy#grep(pattern) {|item| ... } -> Enumerator::Lazy (34.0)

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

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

//emlist[例][ruby]{
(100..Float::INFINITY).lazy.map(&:to_s).grep(/\A(\d)\1+\z/)
# => #<Enumerator::Lazy: #<Enumerator::Lazy: #<Enumerator::Lazy: 100..Infinity>:map>:grep(/\A(\d)\1+\z/)>
(100..Float::INFINIT...
...Y).lazy.map(&:to_s).grep(/\A(\d)\1+\z/).take(10).force
# => ["111", "222", "333", "444", "555", "666", "777", "888", "999", "1111"]
//}

@see Enumerable#grep, Enumerable#grep_v, Enumerator::Lazy#grep_v...

絞り込み条件を変える

Enumerator::Lazy#grep_v(pattern) {|item| ... } -> Enumerator::Lazy (34.0)

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

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

//emlist[例][ruby]{
(100..Float::INFINITY).lazy.map(&:to_s).grep_v(/(\d).*\1/)
# => #<Enumerator::Lazy: #<Enumerator::Lazy: #<Enumerator::Lazy: 100..Infinity>:map>:grep_v(/(\d).*\1/)>
(100..Float::INFINIT...
...Y).lazy.map(&:to_s).grep_v(/(\d).*\1/).take(15).force
# => ["102", "103", "104", "105", "106", "107", "108", "109", "120", "123", "124", "125", "126", "127", "128"]
//}

@see Enumerable#grep_v, Enumerable#grep, Enumerator::Lazy#grep...

Enumerator::Lazy#take(n) -> Enumerator::Lazy (34.0)

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

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

n が大きな数 (100000とか) の場合に備えて再定義されています。
配列が必要な場合は Enumerable#first を使って下さい。

@param n 要素数を指定します。

@raise Arg...
...umentError n に負の数を指定した場合に発生します。

//emlist[例][ruby]{
1.step.lazy.take(5)
# => #<Enumerator::Lazy: #<Enumerator::Lazy: #<Enumerator: 1:step>>:take(5)>

1.step.lazy.take(5).force
# => [1, 2, 3, 4, 5]
//}

@see Enumerable#take...

Enumerator::Lazy#zip(*lists) -> Enumerator::Lazy (34.0)

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

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

ただし一貫性のため、ブロック付きで呼び出した場合は Enumerable#zip と
同じ挙動になります。

//emlist[例][ruby]{
1.step.lazy.zip(('a'..'z').cycle)
# => #<Enumerator::Lazy: #...
...<Enumerator::Lazy: #<Enumerator: 1:step>>:zip(#<Enumerator: "a".."z":cycle>)>

1.step.lazy.zip(('a'..'z').cycle).take(30).force.last(6)
# => [[25, "y"], [26, "z"], [27, "a"], [28, "b"], [29, "c"], [30, "d"]]
//}

@see Enumerable#zip...

Enumerator::Lazy#zip(*lists) {|v1, v2, ...| ... } -> nil (34.0)

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

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

ただし一貫性のため、ブロック付きで呼び出した場合は Enumerable#zip と
同じ挙動になります。

//emlist[例][ruby]{
1.step.lazy.zip(('a'..'z').cycle)
# => #<Enumerator::Lazy: #...
...<Enumerator::Lazy: #<Enumerator: 1:step>>:zip(#<Enumerator: "a".."z":cycle>)>

1.step.lazy.zip(('a'..'z').cycle).take(30).force.last(6)
# => [[25, "y"], [26, "z"], [27, "a"], [28, "b"], [29, "c"], [30, "d"]]
//}

@see Enumerable#zip...

Enumerator::Lazy#chunk {|elt| ... } -> Enumerator::Lazy (28.0)

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

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

//emlist[例][ruby]{
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
# => [[fa...
...lse, [1, 2]], [true, [3]], [false, [4, 5]], [true, [6]], [false, [7, 8]]]
//}

@see Enumerable#chunk...

絞り込み条件を変える

Enumerator::Lazy#chunk(initial_state) {|elt, state| ... } -> Enumerator::Lazy (28.0)

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

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

//emlist[例][ruby]{
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
# => [[fa...
...lse, [1, 2]], [true, [3]], [false, [4, 5]], [true, [6]], [false, [7, 8]]]
//}

@see Enumerable#chunk...
<< 1 2 3 ... > >>