Skip to content

Commit f2b0a68

Browse files
committed
Update Str a bit
1 parent e311356 commit f2b0a68

File tree

1 file changed

+43
-23
lines changed

1 file changed

+43
-23
lines changed

lib/Type/Str.pod

Lines changed: 43 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@ Built-in class for strings. Objects of type C<Str> are immutable.
88
99
=head1 Methods
1010
11-
=head2 routine chop
11+
=head2 routine chop
1212
1313
multi sub chop(Str:D) returns Str:D
14-
multi method chop(Str:D:) returns Str:D
14+
multi method chop(Str:D: $chars = 1) returns Str:D
1515
16-
Returns the string with one character removed from the end.
16+
Returns the string with C<$chars> characters removed from the end.
1717
18-
=head2 routine chomp
18+
=head2 routine chomp
1919
2020
multi sub chomp(Str:D ) returns Str:D
2121
multi method chomp(Str:D:) returns Str:D
@@ -56,7 +56,7 @@ Does a Unicode "titlecase" operation, that is changes the first character in
5656
the string to title case, or to upper case if the character has no title case
5757
mapping
5858
59-
(Not implemented in Rakudo and Niecza)
59+
(Not implemented in Niecza)
6060
6161
=head2 routine tclc
6262
@@ -80,35 +80,33 @@ case
8080
8181
=head2 routine wordcase
8282
83-
multi sub wordcase(Str:D :&filter = &lc, :%exceptions = set()) returns Str
84-
multi method wordcase(Str:D: :&filter = &lc, :%exceptions = set()) returns Str
85-
86-
Performs a Unicode titlecase operation on the first character of
87-
each word of the string (as defined by a regex C<«> boundary),
88-
and forces the rest of the letters through a filter that defaults
89-
to L<lc>. After this operation, if any exceptions are supplied and
90-
if the word is found in the set of exceptions, the first character is also
91-
forced through the filter. Note that the exceptions must be spelled with
92-
an initial titlecase, such as "By" or "And", to produce "by" or "and".
83+
=for code :allow<L>
84+
multi sub wordcase(Cool $x) returns Str
85+
multi sub wordcase(Str:D $x) returns Str
86+
multi method wordcase(Str:D: :&filter = &L<tclc>, Mu :$where = True) returns Str
9387
94-
(Not implemented in Rakudo and Niecza)
88+
Returns a string in which C<&filter> has been applied to all the words
89+
that match C<$where>. By default, this means that the first letter of
90+
every word is capitalized, and all the other letters lowercased.
9591
96-
=head2 method lcfirst (DEPRECATED)
92+
=head2 method lcfirst
9793
9894
Perl 6 does not have a C<lcfirst> function.
9995
100-
=head2 method ucfirst (DEPRECATED)
96+
=head2 method ucfirst
10197
10298
Perl 6 does not have a C<ucfirst> function. See L<tc>.
10399
104-
=head2 method length (FORBIDDEN)
100+
=head2 method length
105101
106102
Perl 6 does not have a C<length> function. See L<chars> or L<elems>.
107103
108104
=head2 routine chars
109105
110-
multi sub chars(Str:D ) returns Int:D
111-
multi method chars(Str:D:) returns Int:D
106+
multi sub chars(Cool $x) returns Int:D
107+
multi sub chars(Str:D $x) returns Int:D
108+
multi sub chars(str $x) returns int
109+
multi method chars(Str:D:) returns Int:D
112110
113111
Returns the number of characters in the string in the current
114112
(lexically scoped) idea of what a normal character is, usually graphemes.
@@ -124,8 +122,8 @@ C<$str.encode('ISO-8859-1')> a C<buf8>.
124122
125123
=head2 routine index
126124
127-
multi sub index(Str:D, Str:D $needle, Int $startpos = 0) returns StrPos
128-
multi method index(Str:D: Str:D $needle, Int $startpos = 0) returns StrPos
125+
multi sub index(Cool $s, Str:D $needle, Cool $startpos = 0) returns Int
126+
multi method index(Cool $needle, Cool $startpos = 0) returns Int
129127
130128
Searches for C<$needle> in the string starting from C<$startpos>. It returns
131129
the offset into the string where C<$needle> was found, and an undefined value
@@ -455,6 +453,22 @@ Returns the codepoint number of the first character of the string
455453
456454
Returns a list of codepoint numbers, one for each character in the string.
457455
456+
=head2 method indent
457+
458+
proto method indent($)
459+
multi method indent(Int $steps where { $_ == 0 } )
460+
multi method indent(Int $steps where { $_ > 0 } )
461+
multi method indent($steps where { .isa(Whatever) || .isa(Int) && $_ < 0 )
462+
463+
Indents each line of the string by C<$steps>, if C<$steps> is positive,
464+
or dedents it by C<-$steps> if C<$steps> is negative. if C<$steps> is
465+
L<C<*>|*>, then the string is dedented to the margin:
466+
467+
=begin code
468+
" indented by 2 spaces\n indented even more".indent(*)
469+
eq "indented by 2 spaces\n indented even more"
470+
=end code
471+
458472
=head2 method trim
459473
460474
method trim(Str:D:) returns Str
@@ -483,5 +497,11 @@ Remove the whitespace characters from the end of a string. See also L<trim>.
483497
484498
Remove the whitespace characters from the beginning of a string. See also L<trim>.
485499
500+
=head2 method ACCEPTS
501+
502+
multi method ACCEPTS(Str:D: $other)
503+
504+
Returns C<True> if the string is L<the same as|eq> C<$other>.
505+
486506
=end pod
487507

0 commit comments

Comments
 (0)