るりまサーチ

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

別のキーワード

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

キーワード

検索結果

<< < 1 2 >>

Enumerable#each_entry {|obj| block} -> self (8010.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_with_index(*args) -> Enumerator (8010.0)

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

...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 (8010.0)

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

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