spand
11/11/2020, 12:19 PMval (p1,p2) = pair ?: null to null
Animesh Sahu
11/11/2020, 1:41 PMoperator fun <T, V> Pair<T, V>?.component1(): T? = null
operator fun <T, V> Pair<T, V>?.component2(): V? = null
val (p1,p2) = pair
But that'd only work for pair for example. You've to redefine these things for triple, data classes, etc.spand
11/11/2020, 1:59 PMpair?.let { (p1,p2) ->
}
spand
11/11/2020, 1:59 PMIrving Rivas
11/11/2020, 2:33 PMIrving Rivas
11/11/2020, 2:35 PMIrving Rivas
11/11/2020, 2:35 PMIrving Rivas
11/11/2020, 2:42 PMinline fun <T>valueOrDefault(value:T?,default:T):T = value?:default
which is easy on the eyes on the calling siteNir
11/11/2020, 3:42 PMIrving Rivas
11/11/2020, 3:53 PM.let {(p1,p2)-> }
is what I find harder to parse.Irving Rivas
11/11/2020, 3:54 PMNir
11/11/2020, 4:18 PMIrving Rivas
11/11/2020, 4:21 PM