Last active
May 14, 2017 18:03
-
-
Save dogbert17/d76977c986df929f5febd14ea308ea74 to your computer and use it in GitHub Desktop.
Attempt to document Str.indices
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
=head2 method indices | |
Defined as: | |
multi method indices(Str:D: Str:D $needle, :$overlap --> List:D) | |
multi method indices(Str:D: Str:D $needle, Int:D $start, :$overlap --> List:D) | |
Searches for all occurances of C<$needle> in the string starting from position | |
C<$start>, or zero if it is not specified, and returns a List with all offsets | |
in the string where C<$needle> was found, or an empty list if it was not found. | |
If the optional parameter C<:overlap> is specified the search continues from the | |
index directly following the previous match, otherwise the search will continue | |
from the first index after the previous match. | |
say "banana".indices("a"); # OUTPUT: «(1 3 5)» | |
say "banana".indices("ana"); # OUTPUT: «(1)» | |
say "banana".indices("ana", :overlap); # OUTPUT: «(1 3)» | |
say "banana".indices("ana", 2); # OUTPUT: «(3)» |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I don't know how you feel about it, but I feel like it's easier to read
otherwise the search will continue after the previous match.
instead ofotherwise the search will continue from the first index after the previous match.