Skip to content

Commit c3ae3ca

Browse files
committed
Separate output by a comma in containers versus values gotcha
This makes the output a little clearer and thus hopefully the point which is being made clearer.
1 parent fa8f12f commit c3ae3ca

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

lib/Language/traps.pod

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,8 @@ Ways to match whitespace:
140140
Beginners might expect a variable in a C<Capture> to supply its current
141141
value when that C<Capture> is later used. For example:
142142
143-
$perl6 -e 'my $a = 2; say($a, ++$a)'
144-
33
143+
$ perl6 -e 'my $a = 2; say join ',', ($a, ++$a)'
144+
3,3
145145
146146
Here the C<Capture> contained the B<container> pointed to by C<$a> and the
147147
B<value> of the result of the expression C<++$a>. Since the C<Capture> must
@@ -150,7 +150,7 @@ looks inside the container in C<$a> and so it may already be incremented.
150150
151151
Instead, use an expression that produces a value when you want a value.
152152
153-
$perl6 -e 'my $a = 2; say(+$a, ++$a)'
154-
23
153+
$ perl6 -e 'my $a = 2; say join ',', (+$a, ++$a)'
154+
2,3
155155
156156
=end pod

0 commit comments

Comments
 (0)