0025 Do_while

The do...while loop in Ruby exists

The do..while loop in Ruby is written begin...end while.

0025-do_while_1.png

It’s the begin...end block that enables it to be executed before the condition. Without the block, the condition is executed first.

0025-do_while_2.png

Ruby’s creator regrets this confusion and suggests writing it this way, reversing the condition (The thread on the subject).

0025-do_while_3.png

Link to Ruby documentation for begin...end while.