Keyword.get
You're seeing just the function
get
, go back to Keyword module for more information.
Specs
Gets the value for a specific key
.
If key
does not exist, return the default value
(nil
if no default value).
If duplicated entries exist, the first one is returned.
Use get_values/2
to retrieve all entries.
Examples
iex> Keyword.get([], :a)
nil
iex> Keyword.get([a: 1], :a)
1
iex> Keyword.get([a: 1], :b)
nil
iex> Keyword.get([a: 1], :b, 3)
3
With duplicated keys:
iex> Keyword.get([a: 1, a: 2], :a, 3)
1
iex> Keyword.get([a: 1, a: 2], :b, 3)
3