Created
September 15, 2015 21:40
-
-
Save dha/0a0736b9da74a8e61e49 to your computer and use it in GitHub Desktop.
Proposed Perl 6 while/until documentation. Also planning to place this *above* repeat/while and repeat/until
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
=begin pod | |
=comment TODO Add docs about LABELs | |
The C<while> statement executes the block as long as its condition is | |
true. So | |
=begin code | |
my $x = 1; | |
while $x < 4 { | |
print $x++; | |
} | |
print "\n"; | |
=end code | |
produces | |
=begin code | |
123 | |
=end code | |
Similarly, the C<until> statement executes the block as long as the | |
expression is false. | |
=begin code | |
my $x = 1; | |
until $x > 3 { | |
print $x++; | |
} | |
print "\n"; | |
=end code | |
again produces | |
=begin code | |
123 | |
=end code | |
The condition for C<while> or C<until> can be parenthesized, but there | |
must be a space between the keyword and the opening parenthesis of the | |
condition. | |
Both C<while> and C<until> can be used as statement modifiers. E. g. | |
=begin code | |
$x++ while $x < 12 | |
=end code | |
Also see C<repeat/while> and C<repeat/until> below. | |
=end pod |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment