operator - method

Rational operator -(
  1. Rational other
)

Subtracts other from this Rational.

const Rational(2, 3) - const Rational(4, 3) == const Rational(-2, 3)
const Rational(4, 5) - const Rational(-2, 3) == const Rational(22, 15)

Implementation

Rational operator -(Rational other) => Rational(
      _numerator * other._denominator - _denominator * other._numerator,
      _denominator * other._denominator,
    );