Skip to content

Commit

Permalink
Proactively die on Rational.Str for ZDRs
Browse files Browse the repository at this point in the history
Don't wait until we explode later in the body
  • Loading branch information
zoffixznet committed Sep 23, 2018
1 parent 75ec224 commit a639fa9
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/core/Rational.pm6
Expand Up @@ -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;

Expand Down

0 comments on commit a639fa9

Please sign in to comment.