3 ms·
> Therefore, this line actually says: !didIMakeAMistake() || CIsWrongHere(); > If you understand how short-circuit evaluation works, you can understand th
by mekazu 7y ago
> Therefore, this line actually says:
!didIMakeAMistake() || CIsWrongHere();
> If you understand how short-circuit evaluation works, you can understand that this will result in the following:
if (!didIMakeAMistake())
CIsWrongHere();
Can someone explain this? I’d have thought that was right without the !
- deleted 7y ago[deleted]
- segfaultbuserr 7y agoIt must be a typo. Function calls have the highest priority here, followed by logic NOT and logic OR. !didIMakeAMistake() || CIsWrongHere(); !didIMakeAMistake() is evaluated first (or you can say didIMakeAMistake() is executed and evaluated first, then its result is inverted and checked), if it's true, evaluation is finished. If it's false, CIsWrongHere(); is evaluated. It is indeed equivalent to if (didIMakeAMistake()) /* !didIMakeAMistake() == false? */ CIsWrongHere(); Without the invertion.
- bowero 7y agoThank you guys so much! I've changed it immediately.