redo Repeats the current loop iteration (without reevaluating the loop's condition or getting the next item from an iterator). : redo « Statement « Ruby






redo Repeats the current loop iteration (without reevaluating the loop's condition or getting the next item from an iterator).

i = 0
while(i < 3)   # Prints "0123" instead of "012"
  # Control returns here when redo is executed
  print i
  i += 1
  redo if i == 3
end

 








Related examples in the same category