isn't that function just `fun <K, V> Map<...
# announcements
a
isn't that function just
fun <K, V> Map<K, V?>.filterValuesNotNull() = filterValues { it != null } as Map<K, V>
? I'm not sure I would even define it at all
p
the cast is unchecked
i defined mine like that :
Copy code
fun <K, V> Map<out K, V?>.filterValuesNotNull(): Map<K, V> {
  val result = LinkedHasMap<K, V>()
  for (entry in this) {
    entry.value?.let { result[entry.key] = it }
  }
}
mostly copied from
filterValues
of stdlib
a
even though it's unchecked, I don't see how it could fail
here's an issue you can track though https://youtrack.jetbrains.com/issue/KT-4734
k
This is one of the things-to-think about in the contracts KEEP.