Do while loops in Ruby

I’ve been programming in Ruby for almost a year now and I had no clue this existed. I came across this when I was looking at how best to emulate a do while loop in Ruby. Apparently there is a do-while structure in Ruby, based on my learning from Jeremy Voorhis’ blog post

Here is how it works

begin
     i = 10
     puts i
     i -= 1
end while(i > 1)

This has been another “holy crap how come I did not know this moment”.

Advertisements