DEV Community

BigSpaces
BigSpaces

Posted on

Master Enum (metaphors galore)

This is a tool that is aiding my brain in the Elixir journey: metaphors.

I find much of the documentation out there is rich in details for the initiated, though it may be a challenge for those of us who read through them as one would read through Sanskrit.

As I learn new functions every day, my brain needs mental shelves where to place these new concepts, and metaphors are providing those mental shelves.

Mastering enum seems to be akin to mastering the light saber for a Jedi. My superhero mentor insists that, if I get Enum.map, Enum.reduce, and Enum.filter, I have a good foundation to move forward.

These are the metaphors that are helping me as a starting point to understanding those three functions.

Enum.map is akin to going through all the beads of a rosary.

Enum.filter is akin to looking for a specific book in the library.

Enum.reduce is akin to placing your shopping into the bag.

They do not represent a perfect description. We have the technical documentation for perfection. Alas, when I am learning, they do the work. When I need to decide which function to use, those visuals help me decide which function has the best shot.

Git add .
Git commit -m "Whatever gets the job done..."
Enter fullscreen mode Exit fullscreen mode

BigSpaces

Top comments (3)

Collapse
 
andevr profile image
drew

If you want another metaphor, Enum.reduce is akin to taking all your potatoes and mashing them up into a big ball :D

Collapse
 
brooklinmyers profile image
Brooklin Myers

Enum.map -> skin your potatoes to make skinned potatoes.
Enum.filter -> get rid of ugly looking potatoes.
Enum.reduce -> (Drew's) make your potatoes into mashed potatoes.

Collapse
 
bigspaces profile image
BigSpaces

One day, not very far away, will take that mash and cook a nice recipe :)