I'm not sure if it's a bug or a feature but the calculation functions return a new instance of self().
Returning a new static() would allow better inheritance behaviours (getting an new object of the current class instead of an instance of the base Money class).
I'm not sure if it's a bug or a feature but the calculation functions return a new instance of
self()
.Returning a
new static()
would allow better inheritance behaviours (getting an new object of the current class instead of an instance of the base Money class).