https://kotlinlang.org logo
Title
b

Bernhard

08/27/2018, 3:39 PM
is there a nice way to get from a Set<String?> to a Set<String> then?
s

Shawn

08/27/2018, 3:42 PM
you could filter and then perform an unchecked cast if performance is of utmost priority
b

Bernhard

08/27/2018, 3:43 PM
what's the type safe solution?
s

Shawn

08/27/2018, 3:43 PM
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

Bernhard

08/27/2018, 3:43 PM
can you use that in a sequence as well?
flatmap it?
ah, forget it 🙂
thanks
f

fred.deschenes

08/27/2018, 3:45 PM
you can also do
.filterNotNullTo(mutableSetOf())
to prevent the set->list->set thing
👆 3