Animesh Sahu
12/18/2020, 3:43 PMreturn when {
cond1 -> try { something() } catch (e: Exception) { TODO() /* Goto cond2 */ }
cond2 -> TODO()
else -> throw RuntimeException("Whatever reason")
}
Marc Knaup
12/18/2020, 3:46 PMAnimesh Sahu
12/18/2020, 3:46 PMMarc Knaup
12/18/2020, 3:47 PMcondX
being objects 😅
Anyway, there is no goto or fall-through in Kotlin.Marc Knaup
12/18/2020, 3:48 PMcond2
branch in a local function and simply call it:
onCond2()
ephemient
12/18/2020, 3:50 PMwhen
- and the keywords were reserved for future use and you couldn't use them - but they've abandoned thatRob Elliot
12/18/2020, 4:01 PMbreak
and continue
, and switch
fall through, were generally a good indication that someone was writing code that would be hard to maintain and reason about.