I have something like this:
void MethodToBreak()
{
// do something
if(something)
{
MethodThatBreaks();
return;
}
// do something
}
void MethodThatBreaks()
{
// do something
}
So, I was wondering: is it possible to break execution from: MethodThatBreaks()
? Then, I would have: if(something) MethodThatBreaks();
and if the condition inside if
is true, nothing after that row would be executed.
NOTE: I know it's possible with else
in this case, but I don't want that.
It would be a nightmare to maintain if you were to upset execution of one method from another. Trying to figure out why your control flow is all over the place six months down the line, or for a another developer, would be aneurysm-inducing.
There's nothing wrong with what you're already doing there, although personally I'd use an else
. Is there a particular reason why you don't want to use else
? If it's that the remaining code is too long that's perhaps and indication you should refactor.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With