Skip to content
Permalink
Browse files

Proactively die on Rational.Str for ZDRs

Don't wait until we explode later in the body
  • Loading branch information...
zoffixznet committed Sep 23, 2018
1 parent 75ec224 commit a639fa9cdd62b703c5f21eec443c31a51ea33fb7
Showing with 3 additions and 0 deletions.
  1. +3 −0 src/core/Rational.pm6
@@ -88,6 +88,9 @@ my role Rational[::NuT = Int, ::DeT = ::("NuT")] does Real {
}

multi method Str(::?CLASS:D:) {
$!denominator || die X::Numeric::DivideByZero.new:
:details('when coercing Rational to Str');

my $whole = self.abs.floor;
my $fract = self.abs - $whole;

0 comments on commit a639fa9

Please sign in to comment.
You can’t perform that action at this time.