andries.fc
10/10/2018, 1:48 PMrobstoll
10/10/2018, 1:49 PMmarstran
10/10/2018, 1:50 PMR is null?robstoll
10/10/2018, 1:50 PMrobstoll
10/10/2018, 1:51 PMlistOf(1 to null, 1 to "").filter... => only list(1 to "") is left and has type Pair<Int, String>andries.fc
10/10/2018, 1:52 PMkotlin
val x = p.safer()
if (x != null) // right side is not nullmarstran
10/10/2018, 1:52 PMrobstoll
10/10/2018, 1:52 PMrobstoll
10/10/2018, 1:52 PMmarstran
10/10/2018, 1:53 PMlist.filterNotNull { it.safer() }andries.fc
10/10/2018, 1:53 PMandries.fc
10/10/2018, 1:53 PMrobstoll
10/10/2018, 1:53 PMfilterNotNull does not expect a lambda in my versionrobstoll
10/10/2018, 1:53 PMrobstoll
10/10/2018, 1:54 PMDico
10/10/2018, 1:54 PM<L: Any, R: Any> upper bounds on those type parameters.andries.fc
10/10/2018, 1:54 PMmarstran
10/10/2018, 1:55 PMlist.mapNotNull { it.safer() }robstoll
10/10/2018, 1:55 PMandries.fc
10/10/2018, 1:55 PMandries.fc
10/10/2018, 1:57 PMval unsafeList = listOf("1" to 1, "yes" to null, "no" to 10)
val safeList = unsafeList.asSequence().mapNotNull { it.safer() }.toList()
println("unsafeList = $unsafeList")
println("safeList = $safeList")