るりまサーチ (Ruby 2.7.0)

最速Rubyリファレンスマニュアル検索!
15件ヒット [1-15件を表示] (0.288秒)
トップページ > バージョン:2.7.0[x] > 種類:インスタンスメソッド[x] > クエリ:_builtin[x] > クエリ:each[x] > クラス:Enumerator::Lazy[x]

別のキーワード

  1. _builtin new
  2. _builtin inspect
  3. _builtin []
  4. _builtin to_s

ライブラリ

キーワード

検索結果

Enumerator::Lazy#enum_for(method = :each, *args) -> Enumerator::Lazy (24337.0)

Object#to_enum と同じですが、Enumerator::Lazy を返します。

...Object#to_enum と同じですが、Enumerator::Lazy を返します。

to_enum は「ブロック付きで呼ぶとループを実行し、ブロックを省略した場合は
Enumerator を返す」ようなメソッドを定義するときによく使われます。
このときに lazy 性が...
...正しく引き継がれるように、Lazy#to_enum は
素のEnumerator ではなく Enumerator::Lazy を返すようになっています。

//emlist[例][ruby]{
module Enumerable
# 要素をn回ずつ繰り返すメソッド
# 例:[1,2,3].repeat(2) #=> [1,1,2,2,3,3]
def repeat(n)
ra...

Enumerator::Lazy#enum_for(method = :each, *args) {|*args| block} -> Enumerator::Lazy (24337.0)

Object#to_enum と同じですが、Enumerator::Lazy を返します。

...Object#to_enum と同じですが、Enumerator::Lazy を返します。

to_enum は「ブロック付きで呼ぶとループを実行し、ブロックを省略した場合は
Enumerator を返す」ようなメソッドを定義するときによく使われます。
このときに lazy 性が...
...正しく引き継がれるように、Lazy#to_enum は
素のEnumerator ではなく Enumerator::Lazy を返すようになっています。

//emlist[例][ruby]{
module Enumerable
# 要素をn回ずつ繰り返すメソッド
# 例:[1,2,3].repeat(2) #=> [1,1,2,2,3,3]
def repeat(n)
ra...

Enumerator::Lazy#to_enum(method = :each, *args) -> Enumerator::Lazy (24337.0)

Object#to_enum と同じですが、Enumerator::Lazy を返します。

...Object#to_enum と同じですが、Enumerator::Lazy を返します。

to_enum は「ブロック付きで呼ぶとループを実行し、ブロックを省略した場合は
Enumerator を返す」ようなメソッドを定義するときによく使われます。
このときに lazy 性が...
...正しく引き継がれるように、Lazy#to_enum は
素のEnumerator ではなく Enumerator::Lazy を返すようになっています。

//emlist[例][ruby]{
module Enumerable
# 要素をn回ずつ繰り返すメソッド
# 例:[1,2,3].repeat(2) #=> [1,1,2,2,3,3]
def repeat(n)
ra...

Enumerator::Lazy#to_enum(method = :each, *args) {|*args| block} -> Enumerator::Lazy (24337.0)

Object#to_enum と同じですが、Enumerator::Lazy を返します。

...Object#to_enum と同じですが、Enumerator::Lazy を返します。

to_enum は「ブロック付きで呼ぶとループを実行し、ブロックを省略した場合は
Enumerator を返す」ようなメソッドを定義するときによく使われます。
このときに lazy 性が...
...正しく引き継がれるように、Lazy#to_enum は
素のEnumerator ではなく Enumerator::Lazy を返すようになっています。

//emlist[例][ruby]{
module Enumerable
# 要素をn回ずつ繰り返すメソッド
# 例:[1,2,3].repeat(2) #=> [1,1,2,2,3,3]
def repeat(n)
ra...

Enumerator::Lazy#collect_concat {|item| ... } -> Enumerator::Lazy (24043.0)

ブロックの実行結果をひとつに繋げたものに対してイテレートするような Enumerator::Lazy のインスタンスを返します。

...ブロックの実行結果をひとつに繋げたものに対してイテレートするような
Enumerator::Lazy
のインスタンスを返します。

//emlist[][ruby]{
["foo", "bar"].lazy.flat_map {|i| i.each_char.lazy}.force
#=> ["f", "o", "o", "b", "a", "r"]
//}

ブロックの返した...
...されます。

* x が配列であるか、to_ary メソッドを持つとき
* x が each および force メソッドを持つ (例:Enumerator::Lazy) とき

それ以外のときは、x は分解されず、そのままの値として使われます。

//emlist[][ruby]{
[{a:1}, {b:2}].lazy...

絞り込み条件を変える

Enumerator::Lazy#flat_map {|item| ... } -> Enumerator::Lazy (24043.0)

ブロックの実行結果をひとつに繋げたものに対してイテレートするような Enumerator::Lazy のインスタンスを返します。

...ブロックの実行結果をひとつに繋げたものに対してイテレートするような
Enumerator::Lazy
のインスタンスを返します。

//emlist[][ruby]{
["foo", "bar"].lazy.flat_map {|i| i.each_char.lazy}.force
#=> ["f", "o", "o", "b", "a", "r"]
//}

ブロックの返した...
...されます。

* x が配列であるか、to_ary メソッドを持つとき
* x が each および force メソッドを持つ (例:Enumerator::Lazy) とき

それ以外のときは、x は分解されず、そのままの値として使われます。

//emlist[][ruby]{
[{a:1}, {b:2}].lazy...

Enumerator::Lazy#chunk {|elt| ... } -> Enumerator::Lazy (24025.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...

Enumerator::Lazy#chunk(initial_state) {|elt, state| ... } -> Enumerator::Lazy (24025.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...

Enumerator::Lazy#eager -> Enumerator (24025.0)

自身を遅延評価しない Enumerator に変換して返します。

...返します。

//emlist[例][ruby]{
lazy_enum = (1..).each.lazy

# select が遅延評価されるので終了する
p lazy_enum.class # => Enumerator::Lazy
p lazy_enum.select { |n| n.even? }.first(5)
# => [2, 4, 6, 8, 10]

# select が遅延評価されないので終了しない
enum = lazy_enum...

Enumerator::Lazy#slice_after {|elt| bool } -> Enumerator::Lazy (24025.0)

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

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

//emlist[例][ruby]{
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 }.tak...

絞り込み条件を変える

Enumerator::Lazy#slice_after(pattern) -> Enumerator::Lazy (24025.0)

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

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

//emlist[例][ruby]{
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 }.tak...

Enumerator::Lazy#slice_before {|elt| bool } -> Enumerator::Lazy (24025.0)

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

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

//emlist[例][ruby]{
1.step.lazy.slice_before { |e| e.even? }
# => #<Enumerator::Lazy: #<Enumerator: #<Enumerator::Generator:0x00007f9f31844ce8>:each>>

1.step.lazy.slice_before { |e| e % 3 == 0 }.t...

Enumerator::Lazy#slice_before(initial_state) {|elt, state| bool } -> Enumerator::Lazy (24025.0)

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

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

//emlist[例][ruby]{
1.step.lazy.slice_before { |e| e.even? }
# => #<Enumerator::Lazy: #<Enumerator: #<Enumerator::Generator:0x00007f9f31844ce8>:each>>

1.step.lazy.slice_before { |e| e % 3 == 0 }.t...

Enumerator::Lazy#slice_before(pattern) -> Enumerator::Lazy (24025.0)

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

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

//emlist[例][ruby]{
1.step.lazy.slice_before { |e| e.even? }
# => #<Enumerator::Lazy: #<Enumerator: #<Enumerator::Generator:0x00007f9f31844ce8>:each>>

1.step.lazy.slice_before { |e| e % 3 == 0 }.t...

Enumerator::Lazy#slice_when {|elt_before, elt_after| bool } -> Enumerator::Lazy (24025.0)

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

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

//emlist[例][ruby]{
1.step.lazy.slice_when { |i, j| (i + j) % 5 == 0 }
# => #<Enumerator::Lazy: #<Enumerator: #<Enumerator::Generator:0x00007fce84118348>:each>>

1.step.lazy.slice_when { |i, j| (i +...

絞り込み条件を変える