I have a 2-level-nested map, how can I update each value on the 2nd level? Right now I'm doing this:
items = Enum.map(items, fn(a) ->
a.items2 = Enum.map(a.items2, fn(a2) ->
Map.put(x2, :some_key, 123)
end)
a
end)
An error:
cannot invoke remote function "a.items2/0" inside match.
I basically know what this means, but how to fix it?
Note that a.items2 might also has a nested map in itself.
Enum.map(items, fn({k,v}) ->
{k, put_in(v, [:items2, :some_key], 123)}
end)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With