Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Range and $-sigiled containers are slightly trappy
  • Loading branch information
gfldex committed Jul 23, 2016
1 parent af84958 commit caa99e1
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions doc/Type/Range.pod6
Expand Up @@ -46,6 +46,20 @@ Use C<Inf> or C<*> (Whatever) to indicate an end point to be open-ended.
for 1..* { .say } # start from 1, continue until stopped
for 1..Inf { .say } # the same
=head2 Ranges in subscripts
A Range can be used in a subscript to get a range of values. Please note that
assigning a Range to a scalar container turns the Range into a item. Use
binding, @-sigiled containers or a slip to get what you mean.
my @numbers = <4 8 15 16 23 42>;
my $range := 0..2;
.say for @numbers[$range];
# OUTPUT«4␤8␤15␤»
my @range = 0..2;
.say for @numbers[@range];
# OUTPUT«4␤8␤15␤»
=head1 Methods
=head2 method min
Expand Down

0 comments on commit caa99e1

Please sign in to comment.