operator + method

Rational operator +(
  1. Rational other
)

Adds this Rational to other.

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

Implementation

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