"Sputnik" help  
Sputnik Help
} While (<condition>);


Unlike for, while and until loops, which test the loop condition at the top of the loop, the do...while loop checks its condition at the bottom of the loop.

A do...while loop is similar to a while loop, except that a do...while loop is guaranteed to execute at least one time.



The condition is evaluated just like an If statement. If it is true, the body of the loop is executed again. If it is false, the body of the loop does not execute again (it is guaranteed to execute the body once regardless if the condition is true or not) and flow of control jumps to the next statement just after the for loop.


Do...While statements may be nested.

The Do...While loop in Sputnik is a control structure that allows you to repeatedly execute a block of code at least once, and then continue execution as long as a specified condition remains true. It is also known as the repeat...until loop in some programming languages.

In the Do...While loop, the code block is executed first, and then the condition is evaluated. If the condition is true, the loop continues executing the code block. The loop terminates when the condition becomes false.


Loop Statements
Continue Statement
Redo Statement
Break Statement


Basic Example:

// Local variable declaration:
my $a = 10;
// do loop execution
   say "value of a: $a";
   $a = $a + 1;
} While($a < 20);
// value of a: 10
// value of a: 11
// value of a: 12
// value of a: 13
// value of a: 14
// value of a: 15
// value of a: 16
// value of a: 17
// value of a: 18
// value of a: 19

As we see here the code always executes once:

my $a = 1;
   say "value of a: $a";
} While($a == 0);
// value of a: 1


Cheryl (uberfox@hotmail.com)