クラス
- Enumerator (44)
-
Enumerator
:: Chain (12) - Object (44)
- Pathname (22)
-
WIN32OLE
_ EVENT (11)
モジュール
- Enumerable (83)
キーワード
-
each
_ line (22) -
each
_ with _ index (22) -
each
_ with _ object (22) - entries (11)
-
enum
_ for (22) - handler= (11)
-
to
_ a (11) -
to
_ enum (22) -
to
_ h (17) -
with
_ index (22) -
with
_ object (22)
検索結果
先頭5件
-
Enumerator
:: Chain # each(*args) { |*args| . . . } -> object (24538.0) -
まず最初の繰り返し可能なオブジェクトの each メソッドを args 引数とともに呼び出した後、続く繰り返し可能なオブジェクト も同様に呼び出します。
...まず最初の繰り返し可能なオブジェクトの each メソッドを
args 引数とともに呼び出した後、続く繰り返し可能なオブジェクト
も同様に呼び出します。
ブロックが渡されない場合は Enumerator を返します。... -
Enumerator
:: Chain # each(*args) -> Enumerator (24438.0) -
まず最初の繰り返し可能なオブジェクトの each メソッドを args 引数とともに呼び出した後、続く繰り返し可能なオブジェクト も同様に呼び出します。
...まず最初の繰り返し可能なオブジェクトの each メソッドを
args 引数とともに呼び出した後、続く繰り返し可能なオブジェクト
も同様に呼び出します。
ブロックが渡されない場合は Enumerator を返します。... -
Enumerable
# each _ with _ index(*args) {|item , index| . . . } -> self (18647.0) -
要素とそのインデックスをブロックに渡して繰り返します。
...tor を返します。
Enumerator#with_index は offset 引数を受け取りますが、
each_with_index は受け取りません (引数はイテレータメソッドにそのまま渡されます)。
@param args イテレータメソッド (each など) にそのまま渡されます。
//emli......st[例][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) -> Enumerator (18547.0) -
要素とそのインデックスをブロックに渡して繰り返します。
...tor を返します。
Enumerator#with_index は offset 引数を受け取りますが、
each_with_index は受け取りません (引数はイテレータメソッドにそのまま渡されます)。
@param args イテレータメソッド (each など) にそのまま渡されます。
//emli......st[例][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 _ object(obj) {|(*args) , memo _ obj| . . . } -> object (18522.0) -
与えられた任意のオブジェクトと要素をブロックに渡し繰り返し、最初に与えられたオブジェクトを返します。
...返します。
ブロックを省略した場合は Enumerator を返します。
@param obj 任意のオブジェクトを指定します。
//emlist[例][ruby]{
evens = (1..10).each_with_object([]) {|i, a| a << i*2 }
# => [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]
//}
@see Enumerator#with_object... -
Enumerable
# each _ with _ object(obj) -> Enumerator (18422.0) -
与えられた任意のオブジェクトと要素をブロックに渡し繰り返し、最初に与えられたオブジェクトを返します。
...返します。
ブロックを省略した場合は Enumerator を返します。
@param obj 任意のオブジェクトを指定します。
//emlist[例][ruby]{
evens = (1..10).each_with_object([]) {|i, a| a << i*2 }
# => [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]
//}
@see Enumerator#with_object... -
Pathname
# each _ line(*args) -> Enumerator (15545.0) -
IO.foreach(self.to_s, *args, &block) と同じです。
...IO.foreach(self.to_s, *args, &block) と同じです。
//emlist[例][ruby]{
require "pathname"
IO.write("testfile", "line1\nline2,\nline3\n")
Pathname("testfile").each_line
# => #<Enumerator: IO:foreach("testfile")>
//}
//emlist[例 ブロックを指定][ruby]{
require "pathname"
IO.write("tes......tfile", "line1\nline2,\nline3\n")
Pathname("testfile").each_line {|f| p f }
# => "line1\n"
# => "line2,\n"
# => "line3\n"
//}
//emlist[例 limit を指定][ruby]{
require "pathname"
IO.write("testfile", "line1\nline2,\nline3\n")
Pathname("testfile").each_line(4) {|f| p f }
# => "line"
# => "1\n"......# => "line"
# => "2,\n"
# => "line"
# => "3\n"
//}
//emlist[例 sep を指定][ruby]{
require "pathname"
IO.write("testfile", "line1\nline2,\nline3\n")
Pathname("testfile").each_line(",") {|f| p f }
# => "line1\nline2,"
# => "\nline3\n"
//}
@see IO.foreach... -
Pathname
# each _ line(*args) {|line| . . . } -> nil (15545.0) -
IO.foreach(self.to_s, *args, &block) と同じです。
...IO.foreach(self.to_s, *args, &block) と同じです。
//emlist[例][ruby]{
require "pathname"
IO.write("testfile", "line1\nline2,\nline3\n")
Pathname("testfile").each_line
# => #<Enumerator: IO:foreach("testfile")>
//}
//emlist[例 ブロックを指定][ruby]{
require "pathname"
IO.write("tes......tfile", "line1\nline2,\nline3\n")
Pathname("testfile").each_line {|f| p f }
# => "line1\n"
# => "line2,\n"
# => "line3\n"
//}
//emlist[例 limit を指定][ruby]{
require "pathname"
IO.write("testfile", "line1\nline2,\nline3\n")
Pathname("testfile").each_line(4) {|f| p f }
# => "line"
# => "1\n"......# => "line"
# => "2,\n"
# => "line"
# => "3\n"
//}
//emlist[例 sep を指定][ruby]{
require "pathname"
IO.write("testfile", "line1\nline2,\nline3\n")
Pathname("testfile").each_line(",") {|f| p f }
# => "line1\nline2,"
# => "\nline3\n"
//}
@see IO.foreach... -
Enumerator
# with _ index(offset = 0) {|(*args) , idx| . . . } -> object (12432.0) -
生成時のパラメータに従って、要素にインデックスを添えて繰り返します。 インデックスは offset から始まります。
...デックスは 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|", 1]
# ["bar|", 2]
# ["baz", 3]
//}
生成時のパラメータに従って、要素にインデックスを添えてブロックを繰り......返します。
インデックスは 0 から始まります。
Enumerator#with_index は offset 引数を受け取りますが、
each_with_index は受け取りません (引数はイテレータメソッドにそのまま渡されます)。... -
Enumerable
# entries(*args) -> [object] (12415.0) -
全ての要素を含む配列を返します。
...を返します。
@param args each の呼び出し時に引数として渡されます。
//emlist[例][ruby]{
(1..7).to_a #=> [1, 2, 3, 4, 5, 6, 7]
{ 'a'=>1, 'b'=>2, 'c'=>3 }.to_a #=> [["a", 1], ["b", 2], ["c", 3]]
require 'prime'
Prime.entries 10 #=> [2...