るりまサーチ

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

別のキーワード

  1. _builtin end
  2. ripper end_seen?
  3. _builtin exclude_end?
  4. _builtin end_with?
  5. string end_with?

ライブラリ

クラス

モジュール

キーワード

検索結果

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 (6263.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...

Matrix#each_with_index(which = :all) -> Enumerator (6221.0)

行列の各要素をその位置とともに引数としてブロックを呼び出します。

...を参照してください。

ブロックを省略した場合、 Enumerator を返します。

//emlist[例][ruby]{
require 'matrix'
Matrix[ [1,2], [3,4] ].each_with_index do |e, row, col|
puts "#{e} at #{row}, #{col}"
end

# => 1 at 0, 0
# => 2 at 0, 1
# => 3 at 1, 0
# => 4 at 1, 1
//...

絞り込み条件を変える

Enumerable#each_with_index(*args) {|item, index| ... } -> self (6163.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 {|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...

Matrix#each_with_index(which = :all) {|e, row, col| ... } -> self (6121.0)

行列の各要素をその位置とともに引数としてブロックを呼び出します。

...を参照してください。

ブロックを省略した場合、 Enumerator を返します。

//emlist[例][ruby]{
require 'matrix'
Matrix[ [1,2], [3,4] ].each_with_index do |e, row, col|
puts "#{e} at #{row}, #{col}"
end

# => 1 at 0, 0
# => 2 at 0, 1
# => 3 at 1, 0
# => 4 at 1, 1
//...

NEWS for Ruby 2.7.0 (342.0)

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

...p b #=> 1
p c #=> [2, 3]
end

//}

//emlist[][ruby]{
case {a: 0, b: 1}
in {a: 0, x: 1}
:unreachable
in {a: 0, b: var}
p var #=> 1
end

//}

//emlist[][ruby]{
case -1
in 0 then :unreachable
in 1 then :unreachable
end
#=> NoMatchingPatternError
//}

//emlist{
json = <<END
{
"name": "Alice",
"a...
...>1}
//}

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