Pattern matching with Enum.map in Elixir

Published on

Today I discovered through Jose Valim’s live stream that you can pattern match with Enum.map/2.

For example, to map the commands of the Day 2 Advent of code puzzle, you can leverage the pattern matching with Enum.map:

...
|> Enum.map(fn
"forward " <> number -> ...
"up " <> number -> ...
"down " <> number -> ...
end)

Continue reading

menu