Reputation: 9750
Is there a way to pick properties of a map from a list in elixir?
map = %{
a: 1, b: 2, c: 3
}
do_something(map, [:a, :b]) = %{a: 1, b: 2}
Upvotes: 0
Views: 215
Reputation: 51439
You want Map.take/2:
iex> Map.take(%{a: 1, b: 2, c: 3}, [:a, :b])
%{a: 1, b: 2}
Upvotes: 1