ITP - loops & iterators - do/while loop

A do/while loop is very similar to a while loop, with the only
difference being that the code within the loop gets executed one time,
prior to the conditional check to see if the code should be executed. In
a do/while loop, the while statement is placed at the end of the loop as
opposed to the beginning. Let's write the same loop as we did before
using a do/while structure instead of a simple while loop.

x = gets.chomp.to_i

begin
  puts x
  x -= 1
end while x >= 0

puts "Done!"

One misleading thing about this loop is that there is no do reserved
word used in it. This is because the do/while loop comes from the C
programming language. Instead we use the begin reserved word to denote
the beginning of the do/while loop. In the above example, the two lines
of code within the loop are executed one time, then the conditional
check is performed.