SoftBank.Cldr.Money.sub-exclamation-mark

You're seeing just the function sub-exclamation-mark, go back to SoftBank.Cldr.Money module for more information.

Specs

sub!(money_1 :: Money.t(), money_2 :: Money.t()) :: Money.t() | none()

Subtract one Money value struct from another and raise on error.

Returns either {:ok, money} or {:error, reason}.

Arguments

  • money_1 and money_2 are any valid Money.t types returned by Money.new/2

Returns

  • a Money.t struct or

  • raises an exception

Examples

iex> SoftBank.Cldr.Money.sub! Money.new(:USD, 200), Money.new(:USD, 100)
#Money<:USD, 100>

SoftBank.Cldr.Money.sub! Money.new(:USD, 200), Money.new(:CAD, 500)
** (ArgumentError) Cannot subtract monies with different currencies. Received :USD and :CAD.