Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add back sprintf.
  • Loading branch information
jnthn committed Feb 25, 2010
1 parent 2ab6b38 commit abd99af
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/core/Any-str.pm
Expand Up @@ -218,6 +218,18 @@ augment class Any {
our Str multi method ucfirst() is export {
self gt '' ?? self.substr(0,1).uc ~ self.substr(1) !! ""
}

our Str multi method sprintf(*@args) {
my $result;
try {
$result = pir::sprintf__SSP(~self, (|@args)!PARROT_POSITIONALS);
}
$! ?? fail( "Insufficient arguments supplied to sprintf") !! $result
}

method Str() {
self
}
}

our multi sub ord($string) {
Expand Down Expand Up @@ -252,5 +264,8 @@ our multi split ( Regex $delimiter, Str $input, Int $limit = * ) {
$input.split($delimiter, $limit);
}

our multi sub sprintf($str as Str, *@args) {
$str.sprintf(|@args)
}

# vim: ft=perl6

0 comments on commit abd99af

Please sign in to comment.