Croma.Result.get

You're seeing just the function get, go back to Croma.Result module for more information.

Specs

get(t(a)) :: nil | a when a: any()

Returns the value associated with :ok in the given result. Returns nil if the result is in the form of {:error, _}.

Examples

iex> Croma.Result.get({:ok, 1})
1

iex> Croma.Result.get({:error, :foo})
nil

Specs

get(t(a), a) :: a when a: any()

Returns the value associated with :ok in the given result. Returns default if the result is in the form of {:error, _}.

Examples

iex> Croma.Result.get({:ok, 1}, 0)
1

iex> Croma.Result.get({:error, :foo}, 0)
0