File tree Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -8,6 +8,35 @@ C<List> stores items sequentially and potentially lazily.
8
8
9
9
Indexes into lists and arrays start at 0 by default.
10
10
11
+ You cannot assign to list elements. Use Arrays for that use
12
+ case instead.
13
+
14
+
15
+ = head2 Items, Flattening and Sigils
16
+
17
+ In Perl 6, assigning a C < List > to a scalar variable does not lose
18
+ information. The difference is that iteration generally treats a
19
+ list (or any other list-like object, like a C < Parcel > or an C < Array > )
20
+ inside a scalar as a single element.
21
+
22
+ my @a = 1, 2, 3;
23
+ for @a { } # three iterations
24
+
25
+ my $s = @a;
26
+ for $s { } # one iteration
27
+ for @a.item { } # one iteration
28
+ for $s.list { } # three iterations
29
+
30
+ Combining lists or arrays that are not inclosed into an item container
31
+ generally flattens.
32
+
33
+ my @a = 1, 2, 3;
34
+ my @flat = @a, @a; # six elements
35
+ my @nested = @a.item, @a.item; # two elemnts
36
+
37
+ C < .item > can often be written as C < $( ... ) > , and on an array variable
38
+ even as C < $@a > .
39
+
11
40
= head2 Methods
12
41
13
42
= head3 elems
You can’t perform that action at this time.
0 commit comments