4件ヒット
[1-4件を表示]
(0.068秒)
キーワード
-
each
_ entry (2) -
each
_ with _ index (2)
検索結果
先頭4件
-
Enumerable
# each _ with _ index(*args) -> Enumerator (42406.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
#... -
Enumerable
# each _ with _ index(*args) {|item , index| . . . } -> self (42406.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
#... -
Enumerable
# each _ entry -> Enumerator (42370.0) -
ブロックを各要素に一度ずつ適用します。
...配列として渡されます。
//emlist[例][ruby]{
class Foo
include Enumerable
def each
yield 1
yield 1,2
end
end
Foo.new.each_entry{|o| print o, " -- "}
# => 1 -- [1, 2] --
//}
ブロックを省略した場合は Enumerator が返されます。
@see Enumerable#slice_before... -
Enumerable
# each _ entry {|obj| block} -> self (42370.0) -
ブロックを各要素に一度ずつ適用します。
...配列として渡されます。
//emlist[例][ruby]{
class Foo
include Enumerable
def each
yield 1
yield 1,2
end
end
Foo.new.each_entry{|o| print o, " -- "}
# => 1 -- [1, 2] --
//}
ブロックを省略した場合は Enumerator が返されます。
@see Enumerable#slice_before...