Ofir Bar
02/17/2020, 11:59 AMgetString() is null.
Can I use this with elvis?
I couldn’t find a way (unless using if/else,etc, just exploring something more clean)Leon K
02/17/2020, 12:10 PMif, list, or something.
What you want is a function from pair of Nullable to Nullable pair.
you can define something like this in kotlin yourself:
fun <A, B> Pair<A?, B?>.liftNullability(): Pair<A, B>? = if (first != null && second != null) Pair(first!!, second!!) else nullOfir Bar
02/17/2020, 12:17 PMlist?Leon K
02/17/2020, 12:19 PMlistOf(nullable1, nulalble2).all { it != null }.filterNotNull().let { values -> doSomething(values[0], values[1])}
but please never do this, it's inefficient and extremely error proneOfir Bar
02/17/2020, 12:23 PM