Actually, what would be really cool is a Kernel macro similar to put_in
that would handle various forms of this, let's say it was called
"flow_into". That would allow all of the mechanics of put_in() to work in
a pipe.
def nice_example(map) do
map
|> get_in([:post, :comments, Access.all(), :likes])
|> Enum.sum()
|> flow_into(map[:sum_of_comment_likes])
end
I really found the mechanics of updating complex structures to be
intimidating when I first started using Elixir. put_in was a great
discovery for me that allowed me to make progress without worrying about
the more mundane mechanics of sticking a result in an array that was in a
map.
--
You received this message because you are subscribed to the Google Groups
"elixir-lang-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/elixir-lang-core/31e4b0dd-fffd-454c-b0ce-133ae07d2733%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.