pavel
10/31/2019, 9:29 PMList<Pair<A,B?>>
Is there an easy way to filter out all where second==null
and make the type be List<Pair<A,B>>
?karelpeeters
10/31/2019, 9:35 PMbezrukov
10/31/2019, 9:35 PMPair<A,B?>
To Pair<A,B>?
karelpeeters
10/31/2019, 9:35 PMpavel
10/31/2019, 9:37 PMbezrukov
10/31/2019, 9:37 PMlist.mapNotNull{if (it.second != null) it.first to it.second else null}
pavel
10/31/2019, 9:41 PMList<Pair<A,B?>>
karelpeeters
10/31/2019, 9:45 PMlist.mapNotNull {
val second = it.second
if (second == null) null else it.first to second
}
bezrukov
10/31/2019, 9:48 PMlist.mapNotNull { (first, second) -> second?.let { first to second } }
pavel
10/31/2019, 9:54 PM