@@ -8,14 +8,14 @@ Built-in class for strings. Objects of type C<Str> are immutable.
8
8
9
9
= head1 Methods
10
10
11
- = head2 routine chop
11
+ = head2 routine chop
12
12
13
13
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
15
15
16
- Returns the string with one character removed from the end.
16
+ Returns the string with C < $chars > characters removed from the end.
17
17
18
- = head2 routine chomp
18
+ = head2 routine chomp
19
19
20
20
multi sub chomp(Str:D ) returns Str:D
21
21
multi method chomp(Str:D:) returns Str:D
@@ -56,7 +56,7 @@ Does a Unicode "titlecase" operation, that is changes the first character in
56
56
the string to title case, or to upper case if the character has no title case
57
57
mapping
58
58
59
- (Not implemented in Rakudo and Niecza)
59
+ (Not implemented in Niecza)
60
60
61
61
= head2 routine tclc
62
62
80
80
81
81
= head2 routine wordcase
82
82
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
93
87
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.
95
91
96
- = head2 method lcfirst (DEPRECATED)
92
+ = head2 method lcfirst
97
93
98
94
Perl 6 does not have a C < lcfirst > function.
99
95
100
- = head2 method ucfirst (DEPRECATED)
96
+ = head2 method ucfirst
101
97
102
98
Perl 6 does not have a C < ucfirst > function. See L < tc > .
103
99
104
- = head2 method length (FORBIDDEN)
100
+ = head2 method length
105
101
106
102
Perl 6 does not have a C < length > function. See L < chars > or L < elems > .
107
103
108
104
= head2 routine chars
109
105
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
112
110
113
111
Returns the number of characters in the string in the current
114
112
(lexically scoped) idea of what a normal character is, usually graphemes.
@@ -124,8 +122,8 @@ C<$str.encode('ISO-8859-1')> a C<buf8>.
124
122
125
123
= head2 routine index
126
124
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
129
127
130
128
Searches for C < $needle > in the string starting from C < $startpos > . It returns
131
129
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
455
453
456
454
Returns a list of codepoint numbers, one for each character in the string.
457
455
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
+
458
472
= head2 method trim
459
473
460
474
method trim(Str:D:) returns Str
@@ -483,5 +497,11 @@ Remove the whitespace characters from the end of a string. See also L<trim>.
483
497
484
498
Remove the whitespace characters from the beginning of a string. See also L < trim > .
485
499
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
+
486
506
= end pod
487
507
0 commit comments