0
votes

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}
1

1 Answers

1
votes

You want Map.take/2:

iex> Map.take(%{a: 1, b: 2, c: 3}, [:a, :b])
%{a: 1, b: 2}