Skip to content

Commit

Permalink
Fixes description of lazy statement prefix, refs #534 #2034
Browse files Browse the repository at this point in the history
Thanks for @jnthn clarification in Raku/roast#529
  • Loading branch information
JJ committed Apr 15, 2019
1 parent d166589 commit 4ef6886
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions doc/Language/statement-prefixes.pod6
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ to some statement or statements.
=head2 X<C<lazy>|lazy (statement prefix)>
As a statement prefix, lazy acts on C<for> loops, saving the execution for when
the variable they are assigned for is actually needed.
As a statement prefix, lazy acts in front of any statement, including C<for>
loops, saving the execution for when the variable they are assigned for is
actually needed.
=for code
my $incremented = 0;
Expand All @@ -28,6 +29,11 @@ the loop is only run, when we eagerly evaluate the variable C<$var> that
contains the lazy loop. Eagerness can be applied on a variable in other ways,
such as calling the C<.eager> method on it.
=for code
my @array = lazy { (^3).map( *² ) };
say @array; # OUTPUT: «[...]»
say @array.eager; # OUTPUT: «[0 1 4]␤»
This prefix can also be used
L<in front of C<gather>|/language/control#gather/take> to make the inner
statements behave lazily.
Expand Down

0 comments on commit 4ef6886

Please sign in to comment.