るりまサーチ

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

別のキーワード

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

ライブラリ

クラス

モジュール

キーワード

検索結果

<< 1 2 3 > >>

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

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

...受け取りますが、
each_with_index
は受け取りません (引数はイテレータメソッドにそのまま渡されます)。

@
param args イテレータメソッド (each など) にそのまま渡されます。

//emlist[例][ruby]{
[5, 10, 15].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...

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

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

...受け取りますが、
each_with_index
は受け取りません (引数はイテレータメソッドにそのまま渡されます)。

@
param args イテレータメソッド (each など) にそのまま渡されます。

//emlist[例][ruby]{
[5, 10, 15].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...

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

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

...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
//}

@
param which どの要素に対してブロックを呼び出すのかを Symbol で指定します
@
see Matrix#each...

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

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

...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
//}

@
param which どの要素に対してブロックを呼び出すのかを Symbol で指定します
@
see Matrix#each...

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

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

...渡して評価します。

@
return ブロックを与えられた場合は self を返します。 ブロックを与えられなかった場合は 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#each_with_index {|prime, index| ... } -> self (18120.0)

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

...渡して評価します。

@
return ブロックを与えられた場合は self を返します。 ブロックを与えられなかった場合は 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 -> Enumerator (3020.0)

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

...渡して評価します。

@
return ブロックを与えられた場合は self を返します。 ブロックを与えられなかった場合は 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 (3020.0)

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

...渡して評価します。

@
return ブロックを与えられた場合は self を返します。 ブロックを与えられなかった場合は 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...

ruby 1.6 feature (60.0)

ruby 1.6 feature ruby version 1.6 は安定版です。この版での変更はバグ修正がメイン になります。

...>))

Object.new.instance_eval {
p remove_instance_variable :@foo
}
=> ruby 1.6.7 (2002-03-01) [i586-linux]
nil

=> -:2:in `remove_instance_variable': instance variable @foo not defined (NameError)
ruby 1.6.7 (2002-04-10) [i586-linux]

:...
...わることはなくなりました。((<ruby-dev:17876>))

class Foo
FOO = 1
@
@foo = 1
end

FOO = 2
@
@foo = 2

Foo.module_eval { p FOO, @@foo }

=> ruby 1.6.7 (2002-03-01) [i586-linux]
1
1

=> ruby 1....
...-03-10 メソッドの戻り値

以下のメソッドの戻り値が正しくなりました。((<ruby-bugs-ja:PR#205>))

* ((<Enumerable/each_with_index>)) が self を返すようになった(以前は nil)
* ((<Process/Process.setpgrp>)) が返す値が不定だった。
* ((<String/ljus...
<< 1 2 3 > >>