Skip to content

Commit

Permalink
be smarter about Complex -> Num conversion: allow it if .im == 0
Browse files Browse the repository at this point in the history
  • Loading branch information
Moritz Lenz committed Sep 30, 2009
1 parent 3566baf commit 34e9a64
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/setting/Complex.pm
Expand Up @@ -122,7 +122,13 @@ class Complex {
(1.0 / self).atanh!to-radians($base);
}
multi method Num { die "You can't just coerce a Complex to Num" }
multi method Num {
if $!im == 0 {
$!re;
} else {
fail "You can only coerce a Complex to Num if the imaginary part is zero"
}
}
}
multi sub abs(Complex $x) { $x.abs }
Expand Down

0 comments on commit 34e9a64

Please sign in to comment.