Should I use `someMap.filterValues { it != null }....
# stdlib
m
Should I use
someMap.filterValues { it != null }.mapValues { it.value as Any }
or is there anything like
someList.filterNotNull()
for `Map`s?
i
k
Is there no general solution coming for this? Ie. also for
.filter { it is String }
.
m
@karelpeeters
listOf<Any>().filterIsInstance<String>()
exists.
k
Hmm, okay. Still, I wonder if it is possible to get the typesystem to understand things like this?
i
@karelpeeters It was a use case for contracts to express the relation between
filter
predicate and the return type, however we haven't yet found the way to express that (@dsavvinov correct me if I'm wrong)
k
That's unfortunate. I'm looking forward to the contract stuff though!
m
You can make it yourself 😉