I saw this on an exam a while back but never understood.
Please explain this one to me
AND
&&
OR
||
I saw this on an exam a while back but never understood.
Please explain this one to me
AND
&&
OR
||
Thanks for your response guido.
Could you please help me understand why?
Short answer - because that’s the way it is.
OK, seriously, I guess the precedence could have been decided arbitrarily. But I like to think that some thought was put into it, or at least copied from that found in other languages.
TBH I’ve never worried about it much, I prefer to force the issue by using parentheses. I find it a lot easier to read without needing to remember, and IMHO a few extra characters here and there won’t make a significant gain in performance to make it worth the hassle.