if((x == 5) || (x == 2)) {
[huge block of code that happens]
if(x == 5)
five();
if(x == 2)
two();
}
So I'm checking for either 5 or 2. And there is a huge block of code that happens after either 5 or 2. The problem is that then I want to do different things depending on whether it is 5 or 2. I didn't want to have separate conditionals for 5 or 2 for the huge block of code (duplicating it would be unwieldy). I also didn't like the way I did it above because x
is actually really long.
Is there a way to say something like:
if((x == 5) || (x == 2)) {
[huge block of code that happens]
if(first conditional was true)
five();
if(second conditional was true)
two();
}
I can always do it the way I did above. Just curious if such an option exists.