operator - method

Money operator -(
  1. Money other
)

Subtracts an amount.

The method checks that the currencies are the same.

Implementation

Money operator -(Money other) {
  if (currency != other.currency) {
    throw ArgumentError('Currencies dont\'t match');
  }
  return Money(currency, amount + other.amount);
}