るりまサーチ

最速Rubyリファレンスマニュアル検索!
44件ヒット [1-44件を表示] (0.027秒)
トップページ > クラス:Object[x] > クエリ:Enumerator#size[x]

別のキーワード

  1. enumerator each
  2. each enumerator
  3. enumerator with_index
  4. enumerator with_object
  5. enumerator new

ライブラリ

キーワード

検索結果

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

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

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

ブロックを指定した場合は Enumerator#size がブロックの評価結果を返
します。ブロックパラメータは引数 args です。


@param method メソッド名の文字列かシンボルです。
@param args 呼び出...
...#<Enumerator: [1, 2, 3]:each>
//}

//emlist[例(ブロックを指定する場合)][ruby]{
module Enumerable
def repeat(n)
raise ArgumentError, "#{n} is negative!" if n < 0
unless block_given?
# __method__ はここでは :repeat
return to_enum(__method__, n) do
# size...
...でなければ 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 w }
# => 'hello', 'hello', 'world', 'world'
enum = (1..14).repeat(3)
# => #<Enumerator: 1..14:repeat(...

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

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

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

ブロックを指定した場合は Enumerator#size がブロックの評価結果を返
します。ブロックパラメータは引数 args です。


@param method メソッド名の文字列かシンボルです。
@param args 呼び出...
...#<Enumerator: [1, 2, 3]:each>
//}

//emlist[例(ブロックを指定する場合)][ruby]{
module Enumerable
def repeat(n)
raise ArgumentError, "#{n} is negative!" if n < 0
unless block_given?
# __method__ はここでは :repeat
return to_enum(__method__, n) do
# size...
...でなければ 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 w }
# => 'hello', 'hello', 'world', 'world'
enum = (1..14).repeat(3)
# => #<Enumerator: 1..14:repeat(...

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

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

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

ブロックを指定した場合は Enumerator#size がブロックの評価結果を返
します。ブロックパラメータは引数 args です。


@param method メソッド名の文字列かシンボルです。
@param args 呼び出...
...#<Enumerator: [1, 2, 3]:each>
//}

//emlist[例(ブロックを指定する場合)][ruby]{
module Enumerable
def repeat(n)
raise ArgumentError, "#{n} is negative!" if n < 0
unless block_given?
# __method__ はここでは :repeat
return to_enum(__method__, n) do
# size...
...でなければ 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 w }
# => 'hello', 'hello', 'world', 'world'
enum = (1..14).repeat(3)
# => #<Enumerator: 1..14:repeat(...

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

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

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

ブロックを指定した場合は Enumerator#size がブロックの評価結果を返
します。ブロックパラメータは引数 args です。


@param method メソッド名の文字列かシンボルです。
@param args 呼び出...
...#<Enumerator: [1, 2, 3]:each>
//}

//emlist[例(ブロックを指定する場合)][ruby]{
module Enumerable
def repeat(n)
raise ArgumentError, "#{n} is negative!" if n < 0
unless block_given?
# __method__ はここでは :repeat
return to_enum(__method__, n) do
# size...
...でなければ 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 w }
# => 'hello', 'hello', 'world', 'world'
enum = (1..14).repeat(3)
# => #<Enumerator: 1..14:repeat(...