Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enum.uniq/2 should be Enum.uniq_by/2 #3142

Closed
josevalim opened this issue Mar 4, 2015 · 2 comments · Fixed by #3158
Closed

Enum.uniq/2 should be Enum.uniq_by/2 #3142

josevalim opened this issue Mar 4, 2015 · 2 comments · Fixed by #3158

Comments

@josevalim
Copy link
Member

josevalim commented Mar 4, 2015

We need to deprecate (long term) Enum.uniq/2 and start promoting Enum.uniq_by/2.

We are changing it to make it consistent with everything else in Enum. All functions that allow you to customise how the operation works with anonymous functions end with _by, for example: max_by, min_by, group_by, sort_by, etc. And why do we use the _by? Because some functions already have the second arity version taken, such as sort/2.

@shankardevy
Copy link
Contributor

do you mean creating a new method uniq_by and deprecate the existing? I don't see Enum.uniq_by/2 available currently? I can take up this.

@josevalim
Copy link
Member Author

The idea is to rename the current Enum.uniq/2 to Enum.uniq_by/2 but still leave a Enum.uniq/2 definition that calls Enum.uniq_by/2 because we can't remove code. It will likely be officially removed just on Elixir 2.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging a pull request may close this issue.

2 participants