Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add .fmt to (Set|Bag|Mix)(|Hash)
  • Loading branch information
lizmat committed May 19, 2014
1 parent c179bc3 commit 328c225
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/ChangeLog
Expand Up @@ -17,6 +17,7 @@ New in 2014.05
+ added "subtest code, desc" to Test.pm (inspired by P5's Test::More)
+ Test::Tap::tap_ok and Test::Util::throws_like are now 1 test (using subtest)
+ BagHash<foo>-- on non-existing key no longer fails (as per S02 spec change)
+ (Set|Bag|Mix)(|Hash) now have a .fmt method
+ deprecate $*OS, $*OSVER, $*VM<name>, $*VM<config>, $*PERL<name>
$*PERL<compiler>...
+ added $*KERNEL, $*DISTRO, $*VM, $*PERL as full blown objects
Expand Down
9 changes: 9 additions & 0 deletions src/core/QuantHash.pm
Expand Up @@ -41,6 +41,15 @@ my role QuantHash does Associative {
}
@found;
}

method fmt(QuantHash: Cool $format = "%s\t\%s", $sep = "\n") {
if nqp::p6box_i(nqp::sprintfdirectives( nqp::unbox_s($format.Stringy) )) == 1 {
self.keys.fmt($format, $sep);
}
else {
self.pairs.fmt($format, $sep);
}
}
}

# vim: ft=perl6 expandtab sw=4

0 comments on commit 328c225

Please sign in to comment.