Author: masak Date: 2009-06-23 13:57:17 +0200 (Tue, 23 Jun 2009) New Revision: 27182
Modified: docs/Perl6/Spec/S32-setting-library/Str.pod Log: [S32/Str] Added Int variants to index/rindex/substr There has to be a way to send in an Int to these Str methods. Arguably, StrPos and StrLen are not Ints -- that's their point. Also, removed optionality from the $end param in substr, because IMO that would lead to MMD ties when no third argument is provided. Modified: docs/Perl6/Spec/S32-setting-library/Str.pod =================================================================== --- docs/Perl6/Spec/S32-setting-library/Str.pod 2009-06-23 05:57:28 UTC (rev 27181) +++ docs/Perl6/Spec/S32-setting-library/Str.pod 2009-06-23 11:57:17 UTC (rev 27182) @@ -246,9 +246,11 @@ =item index our StrPos multi method index( Str $string: Str $substring, StrPos $pos = StrPos(0) ) is export + our StrPos multi method index( Str $string: Str $substring, Int $pos ) is export C<index> searches for the first occurrence of C<$substring> in C<$string>, -starting at C<$pos>. +starting at C<$pos>. If $pos is an C<Int>, it is taken to be in the units +of the calling scope, which defaults to "graphemes". The value returned is always a C<StrPos> object. If the substring is found, then the C<StrPos> represents the position of the first @@ -322,6 +324,7 @@ X<rindex> our StrPos multi method rindex( Str $string: Str $substring, StrPos $pos? ) is export + our StrPos multi method rindex( Str $string: Str $substring, Int $pos ) is export Returns the position of the last C<$substring> in C<$string>. If C<$pos> is specified, then the search starts at that location in C<$string>, and @@ -521,8 +524,11 @@ =item substr our Str multi method substr (Str $string: StrPos $start, StrLen $length?) is rw is export - our Str multi method substr (Str $string: StrPos $start, StrPos $end?) is rw is export + our Str multi method substr (Str $string: StrPos $start, StrPos $end) is rw is export our Str multi method substr (Str $string: StrPos $start, Int $length) is rw is export + our Str multi method substr (Str $string: Int $start, StrLen $length?) is rw is export + our Str multi method substr (Str $string: Int $start, StrPos $end) is rw is export + our Str multi method substr (Str $string: Int $start, Int $length) is rw is export C<substr> returns part of an existing string. You control what part by passing a starting position and optionally either an end position or length.