Implicit distinct on creation of Map/HashMap/Set ? #1130
Unanswered
StefanBertels
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
I'm sure I got to this earlier and maybe it was answered before, but I couldn't find it.
When will constructors or converter functions with result typ Map/HashMap/Set will ignore key errors (drop duplicates implicitly =
distinct) and when will they just raise errors like "An element with the same key already exists in the set" (being strict)?It's clear that
data.TryAddRange()will drop items with duplicate key (= implicit distinct).It's clear (to me) that
data.AddRange()should raise an error if there is a duplicate key.But there are differenct other construction options:
xs.ToMap()toMap(xs)Prelude.Map(x,y,z)new Map(...)Seems this is not consistent currently -- some methods do implicit distinct (drop duplicates), some not.
(related, but old/outdated: #277 (comment))
Beta Was this translation helpful? Give feedback.
All reactions