A do-while loop starts with the do
keyword followed by the loop body expression. After that follows the while
keyword, an opening parenthesis (
, the condition expression and a closing parenthesis )
:
do expression while (condition);
The condition expression has to be of type Bool
.
As the syntax suggests, the loop body expression is always evaluated at least once, unlike while loops.