Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
doc subscripts with multiple dimensions
  • Loading branch information
gfldex committed May 16, 2016
1 parent 6e28573 commit c10af6c
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions doc/Language/subscripts.pod
Expand Up @@ -304,9 +304,22 @@ entire arrays / hashes into strings:
=head1 Multiple dimensions
...
=comment TODO: Explain multi-dim subscripts. It's probably best to wait for
jnthn's ongoing refactor to finish before writing this section.
Dimensions in subscripts are separated by a semiconon, allowing to mix lists of
elements and dimensions.
my @twodim = (<a b c>, (1,2,3));
dd @twodim;
# OUTPUT«Array @twodim = [("a", "b", "c"), (1, 2, 3)]␤»
dd @twodim[0,1;1]; # 2nd element of both lists
# OUTPUT«("b", 2)␤»
Multidimensional subscripts can be used to flatten nested lists.
my @toomany = [[<a b>], [1,2]];
dd @toomany;
# OUTPUT«Array @toomany = [["a", "b"], [1, 2]]␤»
dd @toomany[*;*];
# OUTPUT«("a", "b", 1, 2)␤»
=head1 Modifying elements
Expand Down

0 comments on commit c10af6c

Please sign in to comment.