File tree Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -74,11 +74,23 @@ first element of a list is at index number zero:
7474say (1, 2)[0]; # says 1
7575say (1, 2)[1]; # says 2
7676say (1, 2)[2]; # says Nil
77+
78+ Counting backwards from the end is done with the L<C<Whatever>|/type/Whatever> star
79+ (details on the page on L<Subscripts|/language/subscripts#From_the_end>):
7780=for code :skip-test<syntax error>
78- say (1, 2)[-1]; # Error
81+ say (1, 2)[*-1]; # says 2
82+ say (1, 2)[-1]; # Error
83+
84+ To access elements of nested (multidimensional) lists,
85+ separate the indices for different dimensions with semicolons:
7986=for code
8087say ((<a b>,<c d>),(<e f>,<g h>))[1;0;1]; # says "f"
8188
89+ Pulling out multiple elements at once is possible
90+ by passing lists or ranges of indices;
91+ this is described in sections L<Slice indexing context|#Slice_indexing_context>
92+ and L<Range as slice|#Range_as_slice>.
93+
8294=head1 The @ sigil
8395
8496Variables in Raku whose names bear the C<@> sigil are expected to
You can’t perform that action at this time.
0 commit comments