消除 Iterable 和数组中的空值

有时我们需要将类型从 Collection<T?> 更改为 Collections<T>。在那种情况下,filterNotNull 是我们的解决方案。

val a: List<Int?> = listOf(1, 2, 3, null)
val b: List<Int> = a.filterNotNull()