Money.add-exclamation-mark

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

Specs

add!(money_1 :: t(), money_2 :: t()) :: t() | no_return()

Add two Money values and raise on error.

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> Money.add! Money.new(:USD, 200), Money.new(:USD, 100)
#Money<:USD, 300>

Money.add! Money.new(:USD, 200), Money.new(:CAD, 500)
** (ArgumentError) Cannot add two %Money{} with different currencies. Received :USD and :CAD.