Enum.reduce(list, fn item, acc → %{val: String.to_integer(item[“price”]) + String.to_integer(acc[“price”])} end)
** (ArgumentError) errors were found at the given arguments:
The result of the do_something(...) will be passed as the new acc. It is a map (%{val: 200}) after the first round of run.
String.to_integer(%{val: 200}["price"]}) leads to the exception. So you just need to change :val into "price" as the map key to bypass the exception. But the above approaches provided by @hudsonbay@APB9785 and @mpope are better IMO.