routine rindex
1 | class Str |
1.1 | (Str) routine rindex |
2 | class Cool |
2.1 | (Cool) routine rindex |
Documentation for routine rindex
assembled from the following types:
class Str
From Str
(Str) routine rindex
multi sub rindex(Str , Str , Int = .chars --> Int)multi method rindex(Str : Str , Int = .chars --> Int)
Returns the last position of $needle
in $haystack
not after $startpos
. Returns Nil
if $needle
wasn't found.
Examples:
say rindex "Camelia is a butterfly", "a"; # OUTPUT: «11»say rindex "Camelia is a butterfly", "a", 10; # OUTPUT: «6»
class Cool
From Cool
(Cool) routine rindex
Defined as:
multi sub rindex(Str(Cool) , Str(Cool) , Int(Cool) = .chars)multi method rindex(Str(Cool) : Str(Cool) , Int(Cool) = .chars)
Coerces the first two arguments (including the invocant in method form) to Str and $startpos
to Int, and returns the last position of $needle
in $haystack
not after $startpos
. Returns an undefined value if $needle
wasn't found.
See the documentation in type Str for examples.