I have this piece of code
if (!expr1) {
codeblock1;
} elseif (expr2) {
codeblock2;
codeblock1;
}
It is pissing the hell out of me because I am trying to refactor it in such a way that there is no repetitive code, but I keep getting different results.
if (!expr1 || expr2) {
if (expr2) {
codeblock2;
}
codeblock1;
}
What is the logical difference between these two examples?
elseif
. The second code listing will execute codeblock2 and codeblock1 instead.