Skip to content

Commit 0364b59

Browse files
committed
Correct mixed list/item assignment example, dogbert17++
1 parent 0653d31 commit 0364b59

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

doc/Language/variables.pod6

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,10 +120,10 @@ larger expression determines the assignment type:
120120
my ( @array, $num );
121121
@array = $num = 42, "str"; # list assignment
122122
say @array.perl; # OUTPUT: «[42, "str"]␤»
123-
say $num.perl; # OUTPUT: «[42, "str"]␤»
123+
say $num.perl; # OUTPUT: «42␤»
124124
125-
This is because the whole expression is C<@array = $num = 42, "str">, while
126-
C<$num = 42> is not is own separate expression.
125+
The assignment expression is parsed as C<@array = (($num = 42), "str")>,
126+
because item assignment has tighter precedence than the comma.
127127
128128
See L<operators|/language/operators> for more details on precedence.
129129

0 commit comments

Comments
 (0)