るりまサーチ

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

別のキーワード

  1. _builtin each
  2. _builtin each_line
  3. prime each
  4. each
  5. tsort tsort_each

クラス

キーワード

検索結果

Object#enum_for(method = :each, *args) -> Enumerator (18238.0)

Enumerator.new(self, method, *args) を返します。

...る引数です。

//emlist[][ruby]{
str = "xyz"

enum = str.enum_for(:each_byte)
p(a = enum.map{|b| '%02x' % b }) #=> ["78", "79", "7a"]

# protects an array from being modified
a = [1, 2, 3]
p(a.to_enum) #=> #<Enumerator: [1, 2, 3]:each>
//}

//emlist[例(ブロックを指定する場合)][ruby]...
...__ はここでは :repeat
return to_enum(__method__, n) do
# size メソッドが nil でなければ size * n を返す。
sz = size
sz * n if sz
end
end
each
do |*val|
n.times { yield *val }
end
end
end

%i[hello world].repeat(2) { |w| puts...

Object#enum_for(method = :each, *args) {|*args| ... } -> Enumerator (18238.0)

Enumerator.new(self, method, *args) を返します。

...る引数です。

//emlist[][ruby]{
str = "xyz"

enum = str.enum_for(:each_byte)
p(a = enum.map{|b| '%02x' % b }) #=> ["78", "79", "7a"]

# protects an array from being modified
a = [1, 2, 3]
p(a.to_enum) #=> #<Enumerator: [1, 2, 3]:each>
//}

//emlist[例(ブロックを指定する場合)][ruby]...
...__ はここでは :repeat
return to_enum(__method__, n) do
# size メソッドが nil でなければ size * n を返す。
sz = size
sz * n if sz
end
end
each
do |*val|
n.times { yield *val }
end
end
end

%i[hello world].repeat(2) { |w| puts...

Object#to_enum(method = :each, *args) -> Enumerator (3138.0)

Enumerator.new(self, method, *args) を返します。

...る引数です。

//emlist[][ruby]{
str = "xyz"

enum = str.enum_for(:each_byte)
p(a = enum.map{|b| '%02x' % b }) #=> ["78", "79", "7a"]

# protects an array from being modified
a = [1, 2, 3]
p(a.to_enum) #=> #<Enumerator: [1, 2, 3]:each>
//}

//emlist[例(ブロックを指定する場合)][ruby]...
...__ はここでは :repeat
return to_enum(__method__, n) do
# size メソッドが nil でなければ size * n を返す。
sz = size
sz * n if sz
end
end
each
do |*val|
n.times { yield *val }
end
end
end

%i[hello world].repeat(2) { |w| puts...

Object#to_enum(method = :each, *args) {|*args| ... } -> Enumerator (3138.0)

Enumerator.new(self, method, *args) を返します。

...る引数です。

//emlist[][ruby]{
str = "xyz"

enum = str.enum_for(:each_byte)
p(a = enum.map{|b| '%02x' % b }) #=> ["78", "79", "7a"]

# protects an array from being modified
a = [1, 2, 3]
p(a.to_enum) #=> #<Enumerator: [1, 2, 3]:each>
//}

//emlist[例(ブロックを指定する場合)][ruby]...
...__ はここでは :repeat
return to_enum(__method__, n) do
# size メソッドが nil でなければ size * n を返す。
sz = size
sz * n if sz
end
end
each
do |*val|
n.times { yield *val }
end
end
end

%i[hello world].repeat(2) { |w| puts...

Enumerator (60.0)

each 以外のメソッドにも Enumerable の機能を提供するためのラッパークラスです。 また、外部イテレータとしても使えます。

...each 以外のメソッドにも Enumerable の機能を提供するためのラッパークラスです。
また、外部イテレータとしても使えます。

Enumerable モジュールは、 Module#include 先のクラスが持つ
each
メソッドを元に様々なメソッドを提供し...
...ます。
例えば Array#map は Array#each の繰り返しを元にして定義されます。
Enumerator を介することにより String#each_byte のような
異なる名前のイテレータについても each と同様に Enumerable の機能を利用できます。

Enumerator を生成...
...するには Enumerator.newあるいは
Object#to_enum, Object#enum_for を利用します。また、一部の
イテレータはブロックを渡さずに呼び出すと繰り返しを実行する代わりに
enumerator を生成して返します。

=== 注意
外部イテレータとしての...

絞り込み条件を変える