I know that using And (&&) and OR (||) in a condition statement shouldn't be used without parentheses.
So if you should use both conditions you should do (A && !B) || (C && D)
However, in some code I saw that they are not using Parentheses? What would happen then? I thought that didn't compile:
A && !B || C && D
I guess that it would resolve as with SUMS or MULTIPLICATIONS, I mean, resolve them as they are read:
(((A && !B) || C) && D)
And (&&
) has precedence over or (||
) in the order of operations. So, this
A && !B || C && D
Is entirely equivalent to
(A && !B) || (C && D)
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