Is there a cleaner way to do this? In particular ...
# getting-started
m
Is there a cleaner way to do this? In particular I want to be able to do the
someNumber
part in the when but access the value without having to re-evaluate it in the
else
block
Copy code
fun doFoo(): Pair<Boolean, Int> {
        val someNumber = map.filter { someCoolTest(it) }.keys.firstOrNull()
        return when(someNumber) {
            null -> Pair(false, 0)
            else -> Pair(true, someNumber)
        }
    }