Skip to content

Commit 7a68785

Browse files
committed
Add new *-0 behavior with example
Refs #2632
1 parent 34ab4d6 commit 7a68785

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

doc/Language/subscripts.pod6

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,12 +163,15 @@ L<#Truncating slices> and the L<#:v> adverb.
163163
Positional indices are counted from the start of the collection, but there's
164164
also a notation for addressing elements by their position relative to the end:
165165
C<*-1> refers to the last element, C<*-2> to the second-to-last element, and so
166-
on.
166+
on. From version 6.d, C<*-0> refers to the element just beyond the last one
167167
168168
my @alphabet = 'A' .. 'Z';
169169
say @alphabet[*-1]; # OUTPUT: «Z␤»
170170
say @alphabet[*-2]; # OUTPUT: «Y␤»
171171
say @alphabet[*-3]; # OUTPUT: «X␤»
172+
@alphabet[*-0] = 'þ';
173+
say @alphabet;
174+
# OUTPUT: «[A B C D E F G H I J K L M N O P Q R S T U V W X Y Z þ]␤»
172175
173176
B<Note>: The asterisk, which is actually a L<C<Whatever>|/type/Whatever>, is
174177
important. Passing a bare negative integer (e.g. C<@alphabet[-1]>) like you

0 commit comments

Comments
 (0)