Skip to content

Commit e6e9c25

Browse files
committed
Document Str.samecase
... and state that Cool.samecase uses it.
1 parent 6519d52 commit e6e9c25

File tree

2 files changed

+23
-12
lines changed

2 files changed

+23
-12
lines changed

doc/Type/Cool.pod6

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -972,18 +972,10 @@ Defined as:
972972
sub samecase(Cool $string, Cool $pattern)
973973
method samecase(Cool:D: Cool $pattern)
974974
975-
Coerces the invocant (or in sub form, the first argument) to L<Str|/type/Str>,
976-
and returns a copy of C<$string> with case information for each individual
977-
character changed according to C<$pattern>.
978-
979-
B<Note>: The pattern string can contain
980-
three types of characters, i.e. uppercase, lowercase and caseless. For a given
981-
character in C<$pattern> its case information determines the case of the
982-
corresponding character in the result.
983-
984-
If C<$string> is longer than
985-
C<$pattern>, the case information from the last character of C<$pattern> is
986-
applied to the remaining characters of C<$string>.
975+
Coerces the invocant (or in sub form, the
976+
first argument) to L<Str|/type/Str>, and calls
977+
L«C<Str.samecase>|/type/Str#method_samecase» on it.
978+
987979
988980
say "raKu".samecase("A_a_"); # OUTPUT: «Raku␤»
989981
say "rAKU".samecase("Ab"); # OUTPUT: «Raku␤»

doc/Type/Str.pod6

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -506,6 +506,25 @@ convert those:
506506
I<Note:> before being standardized in 2017.12, this routine was known
507507
under its working name of L<parse-names|/routine/parse-names>. This denomination will be removed in the 6.e version.
508508
509+
=head2 method samecase
510+
511+
multi method samecase(Str:D: Str:D $pattern --> Str:D)
512+
513+
Returns a copy of the invocant with case information for each individual
514+
character changed according to C<$pattern>.
515+
516+
B<Note>: The pattern string can contain three types of characters,
517+
i.e. uppercase, lowercase and caseless. For a given character in
518+
C<$pattern> its case information determines the case of the corresponding
519+
character in the result.
520+
521+
If the invocant is longer than C<$pattern>, the case information from
522+
the last character of C<$pattern> is applied to the remaining characters
523+
of the invocant.
524+
525+
say "raKu".samecase("A_a_"); # OUTPUT: «Raku␤»
526+
say "rAKU".samecase("Ab"); # OUTPUT: «Raku␤»
527+
509528
=head2 routine split
510529
511530
=for code :method

0 commit comments

Comments
 (0)