English3000
Why Keyword.drop/2 and Map.drop/2 instead of Enum.drop/2?
I am currently building an adapted API for Elixir…
And I just noticed how many functions of the same name Keyword and Map share.
What I’m wondering is why both the functions were put there instead of just in Enum?
My first guess would be: optimization.
And so my real question is from a design standpoint:
What determines whether a function should go in
Enum?
P.S. I know Enum.drop/2 exists–BUT, it actually does something different.
P.P.S. Whatever the answer is belongs in the docs.
Most Liked
benwilson512
Keyword and Map are Enumerable in the sense that you can sensibly go through each entry one at a time. However they are also key value data structures. There will be a variety of same name functions related to the fact that they are both key value data structures that have nothing to do with iterating through collections.
Enum does not exist as a one stop shop of “every function that applies to multiple data structures”. It is specifically about manipulating Enumerable structures in their capacity of being enumerable.
easco
Most of the contributions I’ve made to the Elixir core code have been contributions to the docs so once you get an answer, I encourage you to fork the Elixir core code and add what you need.
eksperimental
You may want to have a look at this project of mine
https://github.com/eksperimental/elixir_inconsistencies
It may be useful for what you are working on








