るりまサーチ

最速Rubyリファレンスマニュアル検索!
110件ヒット [1-100件を表示] (0.073秒)
トップページ > クエリ:enumerator[x] > クエリ:new[x] > クエリ:with_index[x]

別のキーワード

  1. openssl new
  2. _builtin new
  3. rexml/document new
  4. resolv new
  5. socket new

ライブラリ

モジュール

検索結果

<< 1 2 > >>

Enumerator#with_index(offset = 0) -> Enumerator (27251.0)

生成時のパラメータに従って、要素にインデックスを添えて繰り返します。 インデックスは offset から始まります。

...//emlist[例][ruby]{
str = "xyz"

enum = Enumerator.new {|y| str.each_byte {|b| y << b }}
enum.with_index {|byte, idx| p [byte, idx] }
# => [120, 0]
# [121, 1]
# [122, 2]

require "stringio"
StringIO.new("foo|bar|baz").each("|").with_index(1) {|s, i| p [s, i] }
# => ["foo|",...
...にインデックスを添えてブロックを繰り返します。
インデックスは 0 から始まります。
Enumerator
#with_index は offset 引数を受け取りますが、
each_with_index は受け取りません (引数はイテレータメソッドにそのまま渡されます)。...

Enumerator#with_index(offset = 0) {|(*args), idx| ... } -> object (27151.0)

生成時のパラメータに従って、要素にインデックスを添えて繰り返します。 インデックスは offset から始まります。

...//emlist[例][ruby]{
str = "xyz"

enum = Enumerator.new {|y| str.each_byte {|b| y << b }}
enum.with_index {|byte, idx| p [byte, idx] }
# => [120, 0]
# [121, 1]
# [122, 2]

require "stringio"
StringIO.new("foo|bar|baz").each("|").with_index(1) {|s, i| p [s, i] }
# => ["foo|",...
...にインデックスを添えてブロックを繰り返します。
インデックスは 0 から始まります。
Enumerator
#with_index は offset 引数を受け取りますが、
each_with_index は受け取りません (引数はイテレータメソッドにそのまま渡されます)。...

Prime::PseudoPrimeGenerator#with_index -> Enumerator (18236.0)

与えられたブロックに対して、素数を0起点の連番を渡して評価します。

...を返します。 ブロックを与えられなかった場合は Enumerator を返します。

//emlist[例][ruby]{
require 'prime'
Prime::EratosthenesGenerator.new(10).each_with_index do |prime, index|
p [prime, index]
end
# [2, 0]
# [3, 1]
# [5, 2]
# [7, 3]
//}

@see Enumerator#with_index...

Prime::PseudoPrimeGenerator#with_index {|prime, index| ... } -> self (18136.0)

与えられたブロックに対して、素数を0起点の連番を渡して評価します。

...を返します。 ブロックを与えられなかった場合は Enumerator を返します。

//emlist[例][ruby]{
require 'prime'
Prime::EratosthenesGenerator.new(10).each_with_index do |prime, index|
p [prime, index]
end
# [2, 0]
# [3, 1]
# [5, 2]
# [7, 3]
//}

@see Enumerator#with_index...

Enumerable#each_with_index(*args) -> Enumerator (6257.0)

要素とそのインデックスをブロックに渡して繰り返します。

...ックを省略した場合は、
要素とそのインデックスを繰り返すような
Enumerator
を返します。

Enumerator
#with_index は offset 引数を受け取りますが、
each_with_index は受け取りません (引数はイテレータメソッドにそのまま渡されます)...
...each_with_index do |n, idx|
p [n, idx]
end
# => [5, 0]
# [10, 1]
# [15, 2]
//}

//emlist[引数ありの例][ruby]{
require 'stringio'
StringIO.new("foo|bar|baz").each_with_index("|") do |s, i|
p [s, i]
end
# => ["foo|", 0]
# ["bar|", 1]
# ["baz", 2]
//}

@see Enumerator#with_index...

絞り込み条件を変える

Prime::PseudoPrimeGenerator#each_with_index -> Enumerator (6236.0)

与えられたブロックに対して、素数を0起点の連番を渡して評価します。

...を返します。 ブロックを与えられなかった場合は Enumerator を返します。

//emlist[例][ruby]{
require 'prime'
Prime::EratosthenesGenerator.new(10).each_with_index do |prime, index|
p [prime, index]
end
# [2, 0]
# [3, 1]
# [5, 2]
# [7, 3]
//}

@see Enumerator#with_index...

NEWS for Ruby 2.6.0 (6180.0)

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

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

それぞれのエントリーは参照情報があるため短いです。
十分な情報と共に書かれた全ての変更のリス...
...(1...).each {|index| block } # index が 1 から始まる無限ループ
ary.zip(1..) {|elem, index| block } # ary.each.with_index(1) { }
//}
* キーワード引数のハッシュに Symbol 以外のキーが含まれると例外が発生するようになりました。...
...numerable
* 新規メソッド
* Enumerable#chain はレシーバと引数のそれぞれの要素を順番にイテレートする
Enumerator
::Chain オブジェクトを返します。 15144
* 変更されたメソッド
* Enumerable#to_h はブロックを受け取り...

Enumerable#each_with_index(*args) {|item, index| ... } -> self (6157.0)

要素とそのインデックスをブロックに渡して繰り返します。

...ックを省略した場合は、
要素とそのインデックスを繰り返すような
Enumerator
を返します。

Enumerator
#with_index は offset 引数を受け取りますが、
each_with_index は受け取りません (引数はイテレータメソッドにそのまま渡されます)...
...each_with_index do |n, idx|
p [n, idx]
end
# => [5, 0]
# [10, 1]
# [15, 2]
//}

//emlist[引数ありの例][ruby]{
require 'stringio'
StringIO.new("foo|bar|baz").each_with_index("|") do |s, i|
p [s, i]
end
# => ["foo|", 0]
# ["bar|", 1]
# ["baz", 2]
//}

@see Enumerator#with_index...

NEWS for Ruby 2.7.0 (6156.0)

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

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

それぞれのエントリーは参照情報があるため短いです。
十分な情報と共に書かれた全ての変更のリス...
...>1}
//}

* Enumerator
* 新規メソッド
* 任意のデータ変換からEnumeratorを作成するための
Enumerator
.produceメソッドが追加されました。 14781
* lazy enumerator から lazy ではない enumerator を生成する
Enumerator
::Lazy#eager...
...加されました。 15901
* Enumerator::Yielder#to_procメソッドが追加され、Yielder オブジェクトを
直接他のメソッドのブロック引数として渡せるようになりました。 15618
* Enumerator::Lazy#with_indexメソッドが追加され、...

Prime::PseudoPrimeGenerator#each_with_index {|prime, index| ... } -> self (6136.0)

与えられたブロックに対して、素数を0起点の連番を渡して評価します。

...を返します。 ブロックを与えられなかった場合は Enumerator を返します。

//emlist[例][ruby]{
require 'prime'
Prime::EratosthenesGenerator.new(10).each_with_index do |prime, index|
p [prime, index]
end
# [2, 0]
# [3, 1]
# [5, 2]
# [7, 3]
//}

@see Enumerator#with_index...

絞り込み条件を変える

NEWS for Ruby 2.0.0 (6114.0)

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

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

それぞれのエントリーは参照情報があるため短いです。
十分な情報と共に書かれた全ての変更のリス...
...メソッドです

* Enumerator
* 追加: Enumerator#size サイズを遅延評価するためのメソッドです
* 拡張: Enumerator.new サイズの遅延評価のための引数を一つ受け取るようになりました
* 新規クラス: Enumerator::Lazy 遅延列挙用の...
...もはや Enumerator を返しませんが、ブロックを与えた場合の動作は後方互換性のためまだサポートしています。
//emlist{
str.lines.with_index(1) {|line, lineno| ... } # str.lines が配列を返すのでもう動かない
str.each_line.with_index(1) {|lin...
<< 1 2 > >>