are all Sets in Kotlin LinkedHashSet?
# announcements
b
are all Sets in Kotlin LinkedHashSet?
s
Mostly yes. Same for maps
b
what are the exceptions? jvm native calls?
s
well, theres
toSortedSet()
and
toHashSet()
also but its the wrong way to think about it. In Kotlin the guarantees are specified in the methods ie.
toSet()
that they preserve the iteration order. Not via. a
LinkedHashSet
return type.
b
that’s kinda dangerous if you are using Java code
since a Kotlin Set is also used for Java Set interop
well, I’ll go with
Copy code
.toCollection(LinkedHashSet())