るりまサーチ

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

別のキーワード

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

ライブラリ

クラス

モジュール

キーワード

検索結果

<< 1 2 3 > >>

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

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

...します。

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

//emlist[例][ruby]{
r
equire '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 (24308.0)

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

...します。

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

//emlist[例][ruby]{
r
equire '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 (21320.0)

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

...デックスを繰り返すような
Enumerator を返します。

Enumerator#with_index は offset 引数を受け取りますが、
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]{
r
equire '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 (21320.0)

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

...デックスを繰り返すような
Enumerator を返します。

Enumerator#with_index は offset 引数を受け取りますが、
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]{
r
equire '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 (21308.0)

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

...とができます。
Matrix#each と同じなのでそちらを参照してください。

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

//emlist[例][ruby]{
r
equire '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 (21308.0)

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

...とができます。
Matrix#each と同じなのでそちらを参照してください。

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

//emlist[例][ruby]{
r
equire '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#with_index -> Enumerator (9208.0)

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

...します。

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

//emlist[例][ruby]{
r
equire '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 (9208.0)

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

...します。

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

//emlist[例][ruby]{
r
equire '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 (8292.0)

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

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

((<stable-snapshot|URL:ftp://ftp.netlab.co.jp/pub/lang/ruby/stable-snapshot.tar.gz>)) は、日々更新される安定版の最新ソースです。

== 1.6.8 (2002-12-24) ->...
...stable-snapshot

: 2003-01-22: errno

EAGAIN と EWOULDBLOCK が同じ値のシステムで、EWOULDBLOCK がなくなっ
ていました。現在は、このようなシステムでは、EWOULDBLOCK は、EAGAIN
として定義されています。(これは 1.6.7 とは異なる挙...
...)
=> -:1: [BUG] Segmentation fault
r
uby 1.6.7 (2002-03-01) [i586-linux]
=> ruby 1.6.7 (2002-03-15) [i586-linux]

: 2002-03-10 メソッドの戻り値

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

* ((<Enumerable/each_with_index>)) が...

Hash#filter! -> Enumerator (6206.0)

キーと値を引数としてブロックを評価した結果が真であるような要素を self に残します。

...
filter! と select! はオブジェクトが変更された場合に self を、
されていない場合に nil を返します。

ブロックが与えられなかった場合は、自身と keep_if から生成した
Enumerator オブジェクトを返します。

//emlist[例][ruby]{
h1 =...
...{}
c = ("a".."g")
c.each_with_index {|e, i| h1[i] = e }

h2 = h1.dup
h1.select! # => #<Enumerator: {0=>"a", 1=>"b", 2=>"c", 3=>"d", 4=>"e", 5=>"f", 6=>"g"}:select!>

h1.select! { |k, v| k % 3 == 0 } # => {0=>"a", 3=>"d", 6=>"g"}
h1.select! { |k, v| true } # => nil
h2.keep_if { |k, v| k % 3...
...== 0 } # => {0=>"a", 3=>"d", 6=>"g"}
h2.keep_if { |k, v| true } # => {0=>"a", 3=>"d", 6=>"g"}
//}

@see Hash#select, Hash#delete_if, Hash#reject!...

絞り込み条件を変える

<< 1 2 3 > >>