The constructor of runCatching in kotlin annoys me.
If it is supposed to replace try{}catch{} why I need to still have a default return when using it?
IS THERE ANY WAY TO AVOID DEFAULT RETURN?
example
fun foo(): String {
objects
.runCathing { anyFunctionThatReturnsString() }
.onFailure {
return "error"
}
.onSucess {
return "sucess"
}
return ""
}
on standard java try{}catch{} if i have return inside try and inside catch i don't need a default return out of the block....
why on kotlin i need it? any way to avoid this?