Map.fetch
You're seeing just the function
fetch
, go back to Map module for more information.
Specs
Fetches the value for a specific key
in the given map
.
If map
contains the given key
then its value is returned in the shape of {:ok, value}
.
If map
doesn't contain key
, :error
is returned.
Inlined by the compiler.
Examples
iex> Map.fetch(%{a: 1}, :a)
{:ok, 1}
iex> Map.fetch(%{a: 1}, :b)
:error