Skip to content

Commit 2729ed3

Browse files
committed
document the rest of the methods, closes #2739
1 parent 0899a01 commit 2729ed3

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

doc/Type/Range.pod6

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,53 @@ C<self.elems>. Returns C<False> otherwise.
379379
say (6..10).EXISTS-POS(2); # OUTPUT: «True␤»
380380
say (6..10).EXISTS-POS(7); # OUTPUT: «False␤»
381381
382+
=head2 method AT-POS
383+
384+
Defined as
385+
386+
multi method AT-POS(Range:D: int \pos)
387+
multi method AT-POS(Range:D: int:D \pos)
388+
389+
Checks if the L<Int|/type/Int> position exists and in that case returns the
390+
element in that position.
391+
392+
say (1..4).AT-POS(2) # OUTPUT: «3␤»
393+
394+
=head2 method perl
395+
396+
Defined as
397+
398+
multi method perl(Range:D:)
399+
400+
Returns an implementation-specific string that produces an L<equivalent|/routine/eqv> object
401+
when given to L<EVAL|/routine/EVAL>.
402+
403+
say (1..2).perl # OUTPUT: «1..2␤»
404+
405+
=head2 method fmt
406+
407+
Defined as
408+
409+
method fmt(|c)
410+
411+
Returns a string where C<min> and C<max> in the L<Range|/type/Range> has been formatted
412+
according to C<|c>.
413+
414+
For more information about formats strings, see L<sprintf|/routine/sprintf>.
415+
416+
say (1..2).fmt("Element: %d", ",") # OUTPUT: «Element: 1,Element: 2␤»
417+
418+
=head2 method WHICH
419+
420+
Defined as
421+
422+
multi method WHICH (Range:D:)
423+
424+
This returns a string that identifies the object. The string is composed by the
425+
type of the instance (C<Range>) and the C<min> and C<max> attributes:
426+
427+
say (1..2).WHICH # OUTPUT: «Range|1..2␤»
428+
382429
=head2 sub infix:<+>
383430
384431
multi sub infix:<+>(Range:D \r, Real:D \v)

0 commit comments

Comments
 (0)