routine rindex
Documentation for routine rindex
assembled from the following types:
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.
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»