retry restarts the iteration : retry « Statement « Ruby






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

 








Related examples in the same category

1.The retry statement will start a loop or iterator over entirely.