* Rewrite Kernel#loop in Ruby * Use enum_for(:loop) { Float::INFINITY } Co-authored-by: Ufuk Kayserilioglu <ufuk@paralaus.com> * Limit the scope to rescue StopIteration Co-authored-by: Ufuk Kayserilioglu <ufuk@paralaus.com>
15 lines
184 B
Ruby
15 lines
184 B
Ruby
max = 6000000
|
|
|
|
if defined? Fiber
|
|
gen = (1..max).each
|
|
loop do
|
|
gen.next
|
|
end
|
|
else
|
|
require 'generator'
|
|
gen = Generator.new((0..max))
|
|
while gen.next?
|
|
gen.next
|
|
end
|
|
end
|