Do-while loop


At the beginning of the section on the do-while loop, you mention that the cool developers almost never use it.

Why? What do they prefer to use instead when they want the block to be executed at least once?

Is this true for other programming languages too?

Thank you.


I don’t really know why the do-while loop is unpopular, but I know that you will rarely see it used.

I don’t see anything inherently wrong with it.


The do…while loop is very important exactly when you want to execute a block of statements before test a condition. In this situation, the use of while or for loops is not the best option, once they test the condition before execute the block of statements. Some programmers can use the while loop and copy the code inside the loop and paste before it. This is really a bad practice.