Hi all, I have a question regarding the methods `m...
# codingconventions
j
Hi all, I have a question regarding the methods
mutableSetOf()
and
linkedSetOf()
. Given that both methods return a
LinkedHashSet
is there a recommendation on when to use one vs the other?
d
mutableSetOf
does not guarantee that you get a
LinkedHashSet
. All it guarantees is that you get a mutable set that preserves iteration order.
linkedHashSet
will always return a
LinkedHashSet
. So personally I'd always go for
mutableSetOf
unless you specifically need a
LinkedHashSet
.
2
👍 1
🙏 1