You can use Fixnum # upto with Float :: INFINITY .
0.upto(Float::INFINITY) do |i|
puts "index: #{i}"
end
But I would just use Kernel#loopand track the index myself, because it seems simpler.
i = 0
loop do
puts "index: #{i}"
i += 1
end
So yes, I donβt think there is anything like that Kernel#loop_with_index.
source
share