In Str§
See primary documentation in context for routine wordcase.
multi wordcase(Cool $x --> Str) multi wordcase(Str:D $x --> Str) multi method wordcase(Str:D: :&filter = &tclc, Mu :$where = True --> Str)
Returns a string in which &filter
has been applied to all the words that match $where
. By default, this means that the first letter of every word is capitalized, and all the other letters lowercased.
In Cool§
See primary documentation in context for routine wordcase.
sub wordcase(Str(Cool) $input, :&filter = &tclc, Mu :$where = True) method wordcase(:&filter = &tclc, Mu :$where = True)
Coerces the invocant (or in sub form, the first argument) to Str
, and filters each word that smartmatches against $where
through the &filter
. With the default filter (first character to uppercase, rest to lowercase) and matcher (which accepts everything), this titlecases each word:
say "raku programming".wordcase; # OUTPUT: «Raku Programming»
With a matcher:
say "have fun working on raku".wordcase(:where({ .chars > 3 })); # Have fun Working on Raku
With a customer filter too:
say "have fun working on raku".wordcase(:filter(&uc), :where({ .chars > 3 })); # HAVE fun WORKING on RAKU