The Price class inherits add(), subtract() and divide() from the Fraction class, as well as comparison functions (LT, GT,...).
All of these functions therefore take Fraction as the second argument.
Only the multiply function is overwritten and accepts Price<TQuote, TOtherQuote> as a second argument.
This is nearly the exact opposite behaviour of what I would intuitively expect. It makes sense to multiply or divide a Price with a Fraction, BigIntish or even Percent, but it makes no sense to add, divide or compare two totally different Price Objects and get a Fraction object in return.
What is the reason for this design decision?
The Price class inherits
add()
,subtract()
anddivide()
from the Fraction class, as well as comparison functions (LT, GT,...). All of these functions therefore takeFraction
as the second argument.Only the multiply function is overwritten and accepts
Price<TQuote, TOtherQuote>
as a second argument.This is nearly the exact opposite behaviour of what I would intuitively expect. It makes sense to multiply or divide a Price with a Fraction, BigIntish or even Percent, but it makes no sense to add, divide or compare two totally different Price Objects and get a Fraction object in return. What is the reason for this design decision?