Hi. Is it not kinda weird that a Set in Kotlin all...
# announcements
h
Hi. Is it not kinda weird that a Set in Kotlin allows duplicates when mapping over the set? https://pl.kotl.in/r9b-MCq8p 😮
z
Set.map
returns a
List
, so not really.
If you want to map to a set, you need another
toSet()
after the map
h
DOH 😳
s
if you need a list but still need to avoid duplicates, use
.distinct()
j
You can also
mapInto(LinkedHashSet()) { .. }
h
Thanks, but it was just because i thought it was weird, and i hadn’t cared to look at the types. Mildly embarrassed