Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
be explicit about assiging LoLs to @-sigiled variables
  • Loading branch information
gfldex committed Jul 14, 2016
1 parent 1fceede commit c882c8d
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions doc/Language/list.pod6
Expand Up @@ -44,22 +44,33 @@ first element of a list is at index number zero:
=head1 The @ sigil
Variables in Perl 6 whose names bear the C<@> sigil are expected to
contain some sort of list-like object. Of course, other variables may
contain some sort of list-like object. Of course, other variables may
also contain these objects, but C<@>-sigiled variables always do, and
are expected to act the part.
By default, when you assign a list to an C<@>-sigiled variable, you create
an C<Array>. Those are described below. If, instead you want to put an actual
By default, when you assign a C<List> to an C<@>-sigiled variable, you create
an C<Array>. Those are described below. If, instead you want to put an actual
C<List> into an C<@>-sigiled variable, you can use binding with C<:=> instead.
my @a := 1, 2, 3;
Assigning Lists of Lists to C<@>-sigiled variables does not provide the same
shortcut. In this case the outer List becomes the first element of the Array.
my @a = (1,2; 3,4);
say @a.flat;
# OUTPUT«((1 2) (3 4))␤»
@a := (1,2; 3,4);
say @a.flat;
# OUTPUT«((1 2 3 4)␤»
One of the ways C<@>-sigiled variables act like lists is by always supporting
L<positional subscripting|/language/subscripts>. Anything bound to a C<@>-sigiled
L<positional subscripting|/language/subscripts>. Anything bound to a C<@>-sigiled
value must support the L<Positional|/type/Positional> role which guarantees this:
my @a := 1; # Type check failed in binding; expected Positional but got Int
=head1 Reset a List Container
To remove all elements from a Positional container assign
Expand Down

0 comments on commit c882c8d

Please sign in to comment.