Skip to content

Commit 114c308

Browse files
committed
Mention how to capitalize strings
1 parent 3b6d55b commit 114c308

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

lib/Language/traps.pod

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,26 @@ last element of an array becomes:
201201
my @array = qw{victor alice bob charlie eve};
202202
say @array[*-1]; #=> eve
203203
204+
=head1 Strings
205+
206+
=head2 Capitalizing a string
207+
208+
In Perl 5 one could capitalize a string by using the C<ucfirst> function
209+
210+
say ucfirst "alice"; #=> Alice
211+
212+
The C<ucfirst> function does not exist in Perl 6; one needs to use the
213+
C<tclc> method:
214+
215+
say "alice".tclc; #=> Alice
216+
217+
which is equivalent to
218+
219+
say tclc "alice"; #=> Alice
220+
221+
Here, C<tclc> means "title case for the first character, lower case for the
222+
remaining characters".
223+
204224
=end pod
205225

206226
# vim: expandtab shiftwidth=4 ft=perl6

0 commit comments

Comments
 (0)