sub rindex

Documentation for sub rindex assembled from the following types:

class Cool

From Cool

(Cool) routine rindex

Defined as:

multi sub    rindex(Str(Cool$haystackStr(Cool$needleInt(Cool$startpos = $haystack.chars)
multi method rindex(Str(Cool$haystack: Str(Cool$needleInt(Cool$startpos = $haystack.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:D $haystackStr:D $needleInt $startpos = $haystack.chars --> Int)
multi method rindex(Str:D $haystack: Str:D $needleInt $startpos = $haystack.chars --> Int)

Returns the last position of $needle in $haystack not after $startpos. Returns Nil if $needle wasn't found.


say rindex "Camelia is a butterfly""a";     # OUTPUT: «11␤» 
say rindex "Camelia is a butterfly""a"10# OUTPUT: «6␤»