In a program, I try to check two booleans (returned by a function); condition to check:
- only if any of the returned value is true and the other is false, I have a problem;
- else, if both are true or false, I am ready to move on to the next step.
Which of the following two examples would be an effective way to check the status, or is there a better solution?
a and b are integer values ββon which I check the correctness condition in the isCorrect function, and it returns true or false.
1.
2.
// checking for the correctness of both a and b if (! (isCorrect(a) ^ isCorrect(b))) { // a OR b is incorrect } else { // a AND b are correct or incorrect }
Thanks
Ivar
PS: code readability is not a problem. EDIT: I wanted to have XOR in the second option. In addition, I agree with the parameters == and! =, But what if I had to use logical operators?
source share