Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add an admonition against uncontainerized binding to array elements
  • Loading branch information
skids committed Aug 20, 2015
1 parent d494fbd commit 59e885d
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions lib/Language/containers.pod
Expand Up @@ -183,6 +183,20 @@ The answer is that binding to array elements is recognized at the syntax
level and instead of emitting code for a normal binding operation, a special
method on the array is called that knows how to do the binding itself.
Note that, while supported, one should generally avoid directly binding
uncontainerized things into array elements. Doing so may produce
counter-intuitive results when the array is used later.
my @a = (1,2,3);
@a[0] := 42; # This is not recommended, use assignment instead.
my $b := 42;
@a[1] := $b; # Nor is this.
@a[2] = $b; # ...but this is fine.
@a[1,2] := 1,2; # This is not allowed and will fail.
Operations that mix Lists and Arrays generally protect against such
a thing happening accidentally.
=head2 Flattening, items and containers
The C<%> and C<@> sigils in Perl 6 generally indicate flattening. Hence
Expand Down

0 comments on commit 59e885d

Please sign in to comment.