るりまサーチ

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

別のキーワード

  1. _builtin end
  2. ripper end_seen?
  3. _builtin exclude_end?
  4. _builtin end_with?
  5. rexml end_element

ライブラリ

クラス

検索結果

Object#enum_for(method = :each, *args) -> Enumerator (18151.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]{
module Enumer...
...# 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 w }
# => 'hello', 'hello', 'world', 'world'
enum = (1..14).repeat(3)...

Object#enum_for(method = :each, *args) {|*args| ... } -> Enumerator (18151.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]{
module Enumer...
...# 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 w }
# => 'hello', 'hello', 'world', 'world'
enum = (1..14).repeat(3)...

Enumerator::Lazy#enum_for(method = :each, *args) -> Enumerator::Lazy (18133.0)

Object#to_enum と同じですが、Enumerator::Lazy を返します。

...[ruby]{
module Enumerable
# 要素をn回ずつ繰り返すメソッド
# 例:[1,2,3].repeat(2) #=> [1,1,2,2,3,3]
def repeat(n)
raise ArgumentError if n < 0
if block_given?
each do |*val|
n.times { yield *val }
end

else
to_enum(:repeat, n)
end

end
...

Enumerator::Lazy#enum_for(method = :each, *args) {|*args| block} -> Enumerator::Lazy (18133.0)

Object#to_enum と同じですが、Enumerator::Lazy を返します。

...[ruby]{
module Enumerable
# 要素をn回ずつ繰り返すメソッド
# 例:[1,2,3].repeat(2) #=> [1,1,2,2,3,3]
def repeat(n)
raise ArgumentError if n < 0
if block_given?
each do |*val|
n.times { yield *val }
end

else
to_enum(:repeat, n)
end

end
...

Object#to_enum(method = :each, *args) -> Enumerator (3051.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]{
module Enumer...
...# 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 w }
# => 'hello', 'hello', 'world', 'world'
enum = (1..14).repeat(3)...

絞り込み条件を変える

Object#to_enum(method = :each, *args) {|*args| ... } -> Enumerator (3051.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]{
module Enumer...
...# 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 w }
# => 'hello', 'hello', 'world', 'world'
enum = (1..14).repeat(3)...

Enumerator::Lazy#to_enum(method = :each, *args) -> Enumerator::Lazy (3033.0)

Object#to_enum と同じですが、Enumerator::Lazy を返します。

...[ruby]{
module Enumerable
# 要素をn回ずつ繰り返すメソッド
# 例:[1,2,3].repeat(2) #=> [1,1,2,2,3,3]
def repeat(n)
raise ArgumentError if n < 0
if block_given?
each do |*val|
n.times { yield *val }
end

else
to_enum(:repeat, n)
end

end
...

Enumerator::Lazy#to_enum(method = :each, *args) {|*args| block} -> Enumerator::Lazy (3033.0)

Object#to_enum と同じですが、Enumerator::Lazy を返します。

...[ruby]{
module Enumerable
# 要素をn回ずつ繰り返すメソッド
# 例:[1,2,3].repeat(2) #=> [1,1,2,2,3,3]
def repeat(n)
raise ArgumentError if n < 0
if block_given?
each do |*val|
n.times { yield *val }
end

else
to_enum(:repeat, n)
end

end
...