SoftBank.Cldr.Money.compare
You're seeing just the function
compare
, go back to SoftBank.Cldr.Money module for more information.
Specs
compare(money_1 :: Money.t(), money_2 :: Money.t()) :: :gt | :eq | :lt | {:error, {module(), String.t()}}
Compares two Money
values numerically. If the first number is greater
than the second :gt is returned, if less than :lt is returned, if both
numbers are equal :eq is returned.
Arguments
money_1
andmoney_2
are any validMoney.t
types returned byMoney.new/2
Returns
:gt
|:eq
|:lt
or{:error, {module(), String.t}}
Examples
iex> SoftBank.Cldr.Money.compare Money.new(:USD, 200), Money.new(:USD, 100)
:gt
iex> SoftBank.Cldr.Money.compare Money.new(:USD, 200), Money.new(:USD, 200)
:eq
iex> SoftBank.Cldr.Money.compare Money.new(:USD, 200), Money.new(:USD, 500)
:lt
iex> SoftBank.Cldr.Money.compare Money.new(:USD, 200), Money.new(:CAD, 500)
{:error,
{ArgumentError,
"Cannot compare monies with different currencies. Received :USD and :CAD."}}