Skip to content

Commit

Permalink
Make subs sprintf/printf/samecase/split multi's
Browse files Browse the repository at this point in the history
  • Loading branch information
lizmat committed Feb 28, 2018
1 parent 3a4056b commit 474c512
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/core/Cool.pm
Expand Up @@ -328,7 +328,8 @@ proto sub wordcase($) is pure {*}
multi sub wordcase(Str:D $x) {$x.wordcase }
multi sub wordcase(Cool $x) {$x.Str.wordcase }

sub sprintf(Cool $format, *@args) {
proto sub sprintf(|) {*}
multi sub sprintf(Cool:D $format, *@args) {
CATCH {
when X::Cannot::Lazy {
X::Cannot::Lazy.new(:action('(s)printf')).throw
Expand All @@ -346,9 +347,14 @@ sub sprintf(Cool $format, *@args) {
)
}

sub printf(Cool $format, *@args) { print sprintf $format, @args }
sub samecase(Cool $string, Cool $pattern) { $string.samecase($pattern) }
sub split($pat, Cool $target, |c) { $target.split($pat, |c) }
proto sub printf(|) {*}
multi sub printf(Cool:D $format, *@args) { print sprintf $format, @args }

proto sub samecase(|) {*}
multi sub samecase(Cool:D $string, Cool:D $pattern) { $string.samecase($pattern) }

proto sub split(|) {*}
multi sub split($pat, Cool:D $target, |c) { $target.split($pat, |c) }

proto sub chars($) is pure {*}
multi sub chars(Cool $x) { $x.Str.chars }
Expand Down

0 comments on commit 474c512

Please sign in to comment.