Skip to content

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

3 participants