dagguh
07/06/2017, 2:17 PMfilter must preserve type
if you want to explicitly change the type from List<Pair<Int?, Int>> to List<Pair<Int, Int>>, you can:
fun explicitlyMapType() {
val map = HashMap<Int, Int>()
fun plusOne(i: Int): Int = i + 1
arrayOf(1, 2, 3)
.map { Pair(map[it], it) }
.filter { it.first != null }
.map { Pair(it.first!!, it.second) }
.map { plusOne(it.first) }
}