Skip to content

Call out what happens to duplicate keys in Map.map/2 in the docs #11360

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

Merged
merged 1 commit into from
Nov 3, 2021

Conversation

s3cur3
Copy link
Contributor

@s3cur3 s3cur3 commented Nov 3, 2021

Per the discussion in #11239, this adds a note that if the function you pass to Map.map/2 produces duplicate keys, only the last one will be kept.

@s3cur3 s3cur3 marked this pull request as draft November 3, 2021 11:26
@s3cur3 s3cur3 marked this pull request as ready for review November 3, 2021 11:35
We should probably document what happens when Map.map/2
produces collisions in the keys. Given that the current
implementation uses :maps.from_list/2, I opted to just use
the same verbiage as Map.new/2.
@josevalim josevalim merged commit 6074846 into elixir-lang:master Nov 3, 2021
@josevalim
Copy link
Member

💚 💙 💜 💛 ❤️

@s3cur3 s3cur3 deleted the master branch November 12, 2021 01:56
@garazdawi
Copy link

How does Map.map/2 create duplicate keys? You iterate over all keys, but only replace the values. Am I missing something?

@josevalim
Copy link
Member

Good find @garazdawi!

josevalim added a commit that referenced this pull request Nov 15, 2021
@s3cur3
Copy link
Contributor Author

s3cur3 commented Nov 15, 2021

Oh geez, I totally misunderstood. 🤦‍♂️

josevalim added a commit that referenced this pull request Nov 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants