is there a nice way to get from a Set<String?&g...
# announcements
b
is there a nice way to get from a Set<String?> to a Set<String> then?
s
you could filter and then perform an unchecked cast if performance is of utmost priority
b
what's the type safe solution?
s
set.filterNotNull().toSet()
is concise enough, but decidedly not as performant if your data size is real large
it is less error-prone, however
b
can you use that in a sequence as well?
flatmap it?
ah, forget it 🙂
thanks
f
you can also do
.filterNotNullTo(mutableSetOf())
to prevent the set->list->set thing
👆 3