Depending on how you organize them. A nested if is equivalent to adding a to each of the internal ifs:
if(A) { if(B) { statement1 } else if(C) { statement2 } }
is equivalent to:
if(A and B) { statement1 } else if(A and C) { statement2 }
My advice is to strive for readability and test your logic. You may find DeMorgan Laws useful for re-organizing your logic.
It always annoys me here:
if(A and B) { statement1 statement2 } else if(A and C) { statement1 statement3 } else if(not A) { statement4 }
vs
if(A) { statement1 if(B) { statement2 } else if(C) { statement3 } } else if(not A) { statement4 }
I'm just not sure what is more readable. They are logically equivalent. The first is more tabular and simpler by eye, but repeats statement 1; the second is more nested and a little ugly (in my opinion), but does not repeat the statement. Ultimately, this is a solution because it has nothing to do with the compiler.
source share