Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add first implementation of Cool.fmt .
  • Loading branch information
pmichaud committed Jun 22, 2011
1 parent a099c6c commit 9b36ac2
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/core/Cool.pm
Expand Up @@ -7,7 +7,14 @@ my class Cool {
nqp::p6box_i(nqp::chars(nqp::unbox_s(self.Str)));
}

method fmt($format = '%s') {
nqp::p6box_s(
pir::sprintf__SsP(nqp::unbox_s($format.Stringy), nqp::list(self))
)
}

method substr($start as Int, $length?) {
# TODO: Update this to match the spec.
my Str $str := self.Str;
my Int $len := ($length // $str.chars).Int;
if ($len < 0) {
Expand Down

0 comments on commit 9b36ac2

Please sign in to comment.