The do-while-statement has a quite similar functionality to the
normal while-statement.
do
{
statement;
} while ( );
|
The only difference is that the condition is evaluated after executing the statement inside the brackets. Thus, the statement is executed at least once.
Example:
int i = 1;
do
{
writefln("Executed the statement with i = %d", i);
} while ( i < 1 );
|
Output:
Executed the statement with i = 1 |
Opposed to:
int i = 1;
while ( i < 1 )
{
writefln("Executed the statement with i = %d", i);
}
|
Output:
(Doesn't output anything because i is 1 at the first check!)
|