Skip to content

Commit

Permalink
Fix Num.ACCEPTS(Complex), and implement Rat.ACCEPTS.
Browse files Browse the repository at this point in the history
  • Loading branch information
colomon committed Mar 14, 2010
1 parent 345f63d commit 2751645
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/core/Num.pm
@@ -1,3 +1,5 @@
class Complex { ... }

augment class Num {
multi method ACCEPTS($other) {
if self eq 'NaN' {
Expand All @@ -6,7 +8,7 @@ augment class Num {
$other == self;
}
}
multi method ACCEPTS(::Complex $other) {
multi method ACCEPTS(Complex $other) {
if self eq 'NaN' {
$other.re eq 'NaN' || $other.im eq 'NaN';
} else {
Expand Down
4 changes: 4 additions & 0 deletions src/core/Rat.pm
Expand Up @@ -23,6 +23,10 @@ class Rat {
self.bless(*, :numerator($numerator), :denominator($denominator));
}

multi method ACCEPTS($other) {
self.Num.ACCEPTS($other);
}

multi method perl() { "$!numerator/$!denominator"; }

our Bool multi method Bool() { $!numerator != 0 ?? Bool::True !! Bool::False }
Expand Down

0 comments on commit 2751645

Please sign in to comment.