Skip to content

Commit 86973aa

Browse files
committed
Provide examples that demonstrate repeat statement always runs once
1 parent 9d3992d commit 86973aa

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

doc/Language/control.pod6

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -671,21 +671,41 @@ is evaluated at the end of the loop, even if it appears at the front.
671671
} while $x < 5;
672672
$x.say; # 5
673673
674+
repeat {
675+
$x++;
676+
} while $x < 5;
677+
$x.say; # 6
678+
674679
repeat while $x < 10 {
675680
$x++;
676681
}
677682
$x.say; # 10
678683
684+
repeat while $x < 10 {
685+
$x++;
686+
}
687+
$x.say; # 11
688+
679689
repeat {
680690
$x++;
681691
} until $x >= 15;
682692
$x.say; # 15
683693
694+
repeat {
695+
$x++;
696+
} until $x >= 15;
697+
$x.say; # 16
698+
684699
repeat until $x >= 20 {
685700
$x++;
686701
}
687702
$x.say; # 20
688703
704+
repeat until $x >= 20 {
705+
$x++;
706+
}
707+
$x.say; # 21
708+
689709
All these forms may produce a return value the same way C<loop> does.
690710
691711
=head1 X<return|control flow>

0 commit comments

Comments
 (0)