I have this list:
[%{item: 20706}, %{item: 20704}]
I want to convert it to:
[20706, 20704]
How to do that? Thank you.
I have this list:
[%{item: 20706}, %{item: 20704}]
I want to convert it to:
[20706, 20704]
How to do that? Thank you.
Maybe something like this
list = [%{item: 20706}, %{item: 20704}]
list |> Enum.map(& Map.get(&1, :item))
The Access
functions can make this really nice:
iex(7)> list = [%{item: 20706}, %{item: 20704}]
[%{item: 20706}, %{item: 20704}]
iex(8)> get_in list, [Access.all(), :item]
[20706, 20704]