Skip to content

Commit 9936aa8

Browse files
committed
doc postfix form of for
1 parent a3952cb commit 9936aa8

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

doc/Language/control.pod6

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ There are also C<with> and C<without> statement modifiers:
306306
=head1 X<for|control flow>
307307
308308
The C<for> loop iterates over a list, running the statements inside a L<block|/type/Block>
309-
once on each iteration. If the block takes parameters, the elements of the
309+
once on each iteration. If the block takes parameters, the elements of the
310310
list are provided as arguments.
311311
312312
my @foo = 1..3;
@@ -339,6 +339,12 @@ with missing elements.
339339
}
340340
# OUTPUT«1 2 3␤4 N/A N/A␤»
341341
342+
If the postfix form of C<for> is used a block is not required and the topic is
343+
set for the statement list.
344+
345+
say „I $_ butterflies!“ for <♥ ♥ ♥>;
346+
# OUTPUT«I ♥ butterflies!␤I ♥ butterflies!␤I ♥ butterflies!␤»
347+
342348
A C<for> may be used on lazy lists – it will only take elements from the
343349
list when they are needed, so to read a file line by line, you could
344350
use:

0 commit comments

Comments
 (0)