The retry statement will start a loop or iterator over entirely. : retry « Statement « Ruby






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


# That can be useful if you need to re-run a particular loop iteration.


1.upto(10) do |number|
  puts "1/" + number.to_s + " = " + (1 / Float(number)).to_s
  print "Enter r to retry: "
  gets
  chomp
  retry if $_ == "r"
end

 








Related examples in the same category

1.retry restarts the iteration