Equality operator (
truewhen both operands are in the same currency and have an equal amount.
fiveDollars == fiveDollars; // => true
fiveDollars == sevenDollars; // => false
fiveDollars == fiveEuros; // => false (different currencies)
Money values can be compared with the
>=operators, or the method
compareTo()from the interface
These operators and method
compareTo()can be used only between money values in the same currency. Runtime error will be thrown on any attempt to compare values in different currencies.
fiveDollars < sevenDollars; // => true
fiveDollars > sevenDollars; // => false
fiveEuros < fiveDollars; // throws ArgumentError!