retry restarts the iteration
n = 10 n.times do |x| print x if x == 9 n -= 1 # Decrement n (we won't reach 9 the next time!) retry # Restart the iteration end end