Hi I have code like below:
def something(input1: Int, input2: Int): Try[Int] = {
if (input1 == 0) {
Failure(new RuntimeException("input1 should not be 0"))
}
if (input2 == 0) {
Failure(new RuntimeException("input2 should not be 0"))
}
Success(input2)
}
and I am trying to use the above function like this way:
something(0, 1)
i am expecting the above should return a Failure, but it actually not, it execute the Failure() statement but it still execute the following code block after the failure
if I want to exit this function with the first Failure, how to achieve it? (I know I can do if else if block to avoid executing the following code block but I don't want to do that, assuming there are a lot of checks)