208件ヒット
[1-100件を表示]
(0.068秒)
クラス
-
ARGF
. class (22) - Binding (10)
- Enumerator (22)
-
Enumerator
:: Lazy (44) - Integer (66)
- Object (44)
キーワード
- downto (22)
-
enum
_ for (44) - eof (11)
- eof? (11)
-
local
_ variables (10) -
to
_ enum (44) - upto (22)
-
with
_ object (22)
検索結果
先頭5件
-
Integer
# times {|n| . . . } -> self (26230.0) -
self 回だけ繰り返します。 self が正の整数でない場合は何もしません。
...ら self - 1 までの数値が渡されます。
//emlist[][ruby]{
3.times { puts "Hello, World!" } # Hello, World! と3行続いて表示される。
0.times { puts "Hello, World!" } # 何も表示されない。
5.times {|n| print n } # 01234 と表示される。
//}
@see Integer#... -
Integer
# times -> Enumerator (26130.0) -
self 回だけ繰り返します。 self が正の整数でない場合は何もしません。
...ら self - 1 までの数値が渡されます。
//emlist[][ruby]{
3.times { puts "Hello, World!" } # Hello, World! と3行続いて表示される。
0.times { puts "Hello, World!" } # 何も表示されない。
5.times {|n| print n } # 01234 と表示される。
//}
@see Integer#... -
Enumerator
# with _ object(obj) {|(*args) , memo _ obj| . . . } -> object (8146.0) -
繰り返しの各要素に obj を添えてブロックを繰り返し、obj を返り値として返します。
...][ruby]{
# 0,1,2 と呼びだす enumeratorを作る
to_three = Enumerator.new do |y|
3.times do |x|
y << x
end
end
to_three_with_string = to_three.with_object("foo")
to_three_with_string.each do |x,string|
puts "#{string}: #{x}"
end
# => foo:0
# => foo:1
# => foo:2
//}
@param obj 繰り... -
Object
# enum _ for(method = :each , *args) {|*args| . . . } -> Enumerator (8135.0) -
Enumerator.new(self, method, *args) を返します。
...@param 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>
//}
//eml......でなければ 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 (8135.0) -
Enumerator.new(self, method, *args) を返します。
...@param 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>
//}
//eml......でなければ 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... -
Enumerator
:: Lazy # enum _ for(method = :each , *args) {|*args| block} -> Enumerator :: Lazy (8129.0) -
Object#to_enum と同じですが、Enumerator::Lazy を返します。
...or if n < 0
if block_given?
each do |*val|
n.times { yield *val }
end
else
to_enum(:repeat, n)
end
end
end
r = 1..10
p r.map{|n| n**2}.repeat(2).first(5)
#=> [1, 1, 4, 4, 9]
r = 1..Float::INFINITY
p r.lazy.map{|n| n**2}.repeat(2).first(5)
#=> [1, 1, 4, 4, 9]... -
Enumerator
:: Lazy # to _ enum(method = :each , *args) {|*args| block} -> Enumerator :: Lazy (8129.0) -
Object#to_enum と同じですが、Enumerator::Lazy を返します。
...or if n < 0
if block_given?
each do |*val|
n.times { yield *val }
end
else
to_enum(:repeat, n)
end
end
end
r = 1..10
p r.map{|n| n**2}.repeat(2).first(5)
#=> [1, 1, 4, 4, 9]
r = 1..Float::INFINITY
p r.lazy.map{|n| n**2}.repeat(2).first(5)
#=> [1, 1, 4, 4, 9]... -
Integer
# downto(min) {|n| . . . } -> self (8116.0) -
self から min まで 1 ずつ減らしながらブロックを繰り返し実行します。 self < min であれば何もしません。
...で 1 ずつ減らしながらブロックを繰り返し実行します。
self < min であれば何もしません。
@param min 数値
@return self を返します。
//emlist[][ruby]{
5.downto(1) {|i| print i, " " } # => 5 4 3 2 1
//}
@see Integer#upto, Numeric#step, Integer#times... -
Integer
# upto(max) {|n| . . . } -> Integer (8116.0) -
self から max まで 1 ずつ増やしながら繰り返します。 self > max であれば何もしません。
...self から max まで 1 ずつ増やしながら繰り返します。
self > max であれば何もしません。
@param max 数値
@return self を返します。
//emlist[][ruby]{
5.upto(10) {|i| print i, " " } # => 5 6 7 8 9 10
//}
@see Integer#downto, Numeric#step, Integer#times... -
Enumerator
# with _ object(obj) -> Enumerator (8046.0) -
繰り返しの各要素に obj を添えてブロックを繰り返し、obj を返り値として返します。
...][ruby]{
# 0,1,2 と呼びだす enumeratorを作る
to_three = Enumerator.new do |y|
3.times do |x|
y << x
end
end
to_three_with_string = to_three.with_object("foo")
to_three_with_string.each do |x,string|
puts "#{string}: #{x}"
end
# => foo:0
# => foo:1
# => foo:2
//}
@param obj 繰り...