クラス
-
ARGF
. class (24) - Array (24)
- Binding (11)
- Enumerator (36)
-
Enumerator
:: Lazy (48) - Float (22)
- Integer (72)
- Object (48)
-
Rake
:: FileCreationTask (12) -
Rake
:: FileTask (12) -
Rake
:: Task (12) -
Socket
:: AncillaryData (12) - String (12)
-
Thread
:: ConditionVariable (24) - ThreadsWait (42)
モジュール
- Kernel (12)
キーワード
- * (36)
-
all
_ waits (6) - broadcast (12)
- downto (24)
- empty? (6)
-
enum
_ for (48) - eof (12)
- eof? (12)
- finished? (6)
- join (6)
-
join
_ nowait (6) -
local
_ variables (11) - modified? (12)
- next (12)
-
next
_ float (11) -
next
_ wait (6) -
prev
_ float (11) - signal (12)
- threads (6)
-
to
_ enum (48) - upto (24)
-
with
_ object (24)
検索結果
先頭5件
-
Enumerator
:: Lazy # enum _ for(method = :each , *args) {|*args| block} -> Enumerator :: Lazy (7.0) -
Object#to_enum と同じですが、Enumerator::Lazy を返します。
...# 例:[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
end
r = 1..10
p r.map{|n| n**2}.repeat(2).first(5)
#=> [1, 1, 4, 4, 9]... -
Enumerator
:: Lazy # to _ enum(method = :each , *args) -> Enumerator :: Lazy (7.0) -
Object#to_enum と同じですが、Enumerator::Lazy を返します。
...# 例:[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
end
r = 1..10
p r.map{|n| n**2}.repeat(2).first(5)
#=> [1, 1, 4, 4, 9]... -
Enumerator
:: Lazy # to _ enum(method = :each , *args) {|*args| block} -> Enumerator :: Lazy (7.0) -
Object#to_enum と同じですが、Enumerator::Lazy を返します。
...# 例:[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
end
r = 1..10
p r.map{|n| n**2}.repeat(2).first(5)
#=> [1, 1, 4, 4, 9]... -
Float
# next _ float -> Float (7.0) -
浮動小数点数で表現可能な self の次の値を返します。
...=> 1.734723475976807e-18
p 1.0.next_float - 1.0 # => 2.220446049250313e-16
p 100.0.next_float - 100.0 # => 1.4210854715202004e-14
f = 0.01; 20.times { printf "%-20a %s\n", f, f.to_s; f = f.next_float }
# => 0x1.47ae147ae147bp-7 0.01
# 0x1.47ae147ae147cp-7 0.010000000000000002
# 0x1.47ae14... -
Float
# prev _ float -> Float (7.0) -
浮動小数点数で表現可能な self の前の値を返します。
...> 1.734723475976807e-18
p 1.0 - 1.0.prev_float # => 1.1102230246251565e-16
p 100.0 - 100.0.prev_float # => 1.4210854715202004e-14
f = 0.01; 20.times { printf "%-20a %s\n", f, f.to_s; f = f.prev_float }
# => 0x1.47ae147ae147bp-7 0.01
# 0x1.47ae147ae147ap-7 0.009999999999999998
# 0x1.47ae14... -
Integer
# downto(min) -> Enumerator (7.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
# downto(min) {|n| . . . } -> self (7.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) -> Enumerator (7.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... -
Integer
# upto(max) {|n| . . . } -> Integer (7.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... -
Object
# enum _ for(method = :each , *args) -> Enumerator (7.0) -
Enumerator.new(self, method, *args) を返します。
...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)
# => #...