Skip to content

Latest commit

 

History

History
36 lines (23 loc) · 525 Bytes

Do-while.md

File metadata and controls

36 lines (23 loc) · 525 Bytes
my $val = 0;
repeat {
    say ++$val;
} while $val % 6;

repeat ... until <i>condition</i> is equivalent to do ... while not <i>condition</i>.

my $val = 0;
repeat {
    say ++$val;
} until $val %% 6;

(Here we've used %%, the "divisible-by" operator.)

You can also put the condition before the block, without changing the order of evaluation.

my $val = 0;
repeat while $val % 6 {
    say ++$val;
}