Skip to content

Commit

Permalink
Document WhateverCode end point in Range
Browse files Browse the repository at this point in the history
A WhateverCode end point to the Range operator creates a new WhateverCode
which returns Ranges.

This is covered by roast: https://github.com/perl6/roast/blob/master/S02-types/whatever.t#L34
  • Loading branch information
taboege committed May 9, 2019
1 parent 30c0348 commit 3d32f6e
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions doc/Type/Range.pod6
Expand Up @@ -48,6 +48,18 @@ Use C<∞> or C<*> (Whatever) to indicate an end point to be open-ended.
for 1..* { .say }; # start from 1, continue until stopped
for 1..∞ { .say }; # the same
Beware that a L<WhateverCode|/type/WhateverCode> end point, instead of a plain
Whatever, will go through the range operator and create another WhateverCode
which returns a Range:
=for code
# A Whatever produces the 1..Inf range
say (1..*).WHAT; # OUTPUT: «(Range)␤»
say (1..*); # OUTPUT: «1..Inf␤»
# Upper end point is now a WhateverCode
say (1..*+20).WHAT; # OUTPUT: «(WhateverCode)␤»
say (1..*+20).(22); # OUTPUT: «1..42␤»
Ranges implement L<Positional|/type/Positional> interface, so its elements can
be accessed using an index. In a case when the index given is bigger than the
Range object's size, L<Nil|/type/Nil> object will be returned. The access works
Expand Down

0 comments on commit 3d32f6e

Please sign in to comment.