るりまサーチ

最速Rubyリファレンスマニュアル検索!
1070件ヒット [1-100件を表示] (0.084秒)

別のキーワード

  1. kernel require
  2. getoptlong require_order
  3. rubygems/custom_require require
  4. irb/ext/use-loader irb_require
  5. require execute

検索結果

<< 1 2 3 ... > >>

CSV::Row#index(header, minimum_index = 0) -> Integer (18227.0)

与えられたヘッダの名前に対応するインデックスを返します。

...aram minimum_index このインデックスより後で、ヘッダの名前を探します。
重複しているヘッダがある場合に便利です。

//emlist[例][ruby]{
require
"csv"

row = CSV::Row.new(["header1", "header2", "header1"], [1, 2, 3])
row.index("header1")...
...# => 0
row.index("header1", 1) # => 2
//}

@see CSV::Row#field...

Matrix#index(selector = :all) -> Enumerator (18125.0)

指定した値と一致する要素の位置を [row, column] という配列で返します。 ブロックを与えた場合は各要素を引数としてブロックを呼び出し、 返り値が真であった要素の位置を返します。

...します。この引数の意味は
Matrix#each を参照してください。

//emlist[例][ruby]{
require
'matrix'
Matrix[ [1,2], [3,4] ].index(&:even?) # => [0, 1]
Matrix[ [1,1], [1,1] ].index(1, :strict_lower) # => [1, 0]
//}

value を指定せず、さらにブロックを省略した場合...

Matrix#index(selector = :all) {|e| ... } -> [Integer, Integer] | nil (18125.0)

指定した値と一致する要素の位置を [row, column] という配列で返します。 ブロックを与えた場合は各要素を引数としてブロックを呼び出し、 返り値が真であった要素の位置を返します。

...します。この引数の意味は
Matrix#each を参照してください。

//emlist[例][ruby]{
require
'matrix'
Matrix[ [1,2], [3,4] ].index(&:even?) # => [0, 1]
Matrix[ [1,1], [1,1] ].index(1, :strict_lower) # => [1, 0]
//}

value を指定せず、さらにブロックを省略した場合...

Matrix#index(value, selector = :all) -> [Integer, Integer] | nil (18125.0)

指定した値と一致する要素の位置を [row, column] という配列で返します。 ブロックを与えた場合は各要素を引数としてブロックを呼び出し、 返り値が真であった要素の位置を返します。

...します。この引数の意味は
Matrix#each を参照してください。

//emlist[例][ruby]{
require
'matrix'
Matrix[ [1,2], [3,4] ].index(&:even?) # => [0, 1]
Matrix[ [1,1], [1,1] ].index(1, :strict_lower) # => [1, 0]
//}

value を指定せず、さらにブロックを省略した場合...

CSV::FieldInfo#index -> Integer (18114.0)

行内で何番目のフィールドかわかるゼロベースのインデックスを返します。

...かるゼロベースのインデックスを返します。

//emlist[例][ruby]{
require
'csv'

csv = CSV.new("date1,date2\n2018-07-09,2018-07-10", headers: true)
csv.convert do |field,field_info|
p field_info.index
Date.parse(field)
end
p csv.first

# => 0
# => 1
# => #<CSV::Row "date1":#<Dat...

絞り込み条件を変える

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

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

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

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

@param args イテ...
...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 (6237.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 (6237.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 (6140.0)

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

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

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

@param args イテ...
...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...
<< 1 2 3 ... > >>