Skip to content

Commit e9483ab

Browse files
committed
doc Range as List/Array slice
1 parent 8a5200c commit e9483ab

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

doc/Language/list.pod

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,20 @@ structure in the result:
237237
238238
say ("a","b","c")[(1,2),(0,1)] eqv (("b", "c"), ("a", "b")) # says True
239239
240+
=head2 Range as Slice
241+
242+
A L<C<Range>|/type/Range> is a container for a lower and a upper boundary.
243+
Generating a slice with a C<Range> will include any index between those bounds,
244+
including the bounds. For infinite upper bounderies we agree with
245+
mathematicians that C<Inf> equals C<Inf-1>.
246+
247+
my @a = 1..5;
248+
say @a[0..2]; # OUTPUT«(1 2 3)␤»
249+
say @a[0..^2]; # OUTPUT«(1 2)␤»
250+
say @a[0..*]; # OUTPUT«(1 2 3 4 5)␤␤»
251+
say @a[0..^*]; # OUTPUT«(1 2 3 4 5)␤»
252+
say @a[0..Inf-1]; # OUTPUT«(1 2 3 4 5)␤»
253+
240254
=head2 Array Constructor Context
241255
242256
Inside an Array Literal, the list of initialization values is not in capture

0 commit comments

Comments
 (0)