Skip to content

Commit

Permalink
Add coerce to Numeric
Browse files Browse the repository at this point in the history
  • Loading branch information
FCO committed Apr 1, 2017
1 parent eef7d8e commit 2afe78d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/Heap.pm6
Expand Up @@ -69,6 +69,10 @@ role Heap[$heap_cmp = * cmp *] {
::?CLASS.^name ~ ".new: {@!data.gist}";
}

method Numeric {
+@!data
}

method Array {
@!data
}
Expand Down
2 changes: 2 additions & 0 deletions t/01-test.t
Expand Up @@ -24,6 +24,8 @@ lives-ok {

is-deeply $h.Set, [-1, 1].Set;

is +$h, 2, "Numeric";

my $h1 = Heap.new(1, 2, 3);
my $h2 = Heap.new(3, 2, 1);

Expand Down

0 comments on commit 2afe78d

Please sign in to comment.