Help need for specific boolean logic
CaptchaIsExist CaptchaIsValid = Result
-------------- 开发者_如何学Go ------------- --------
true false = false
Any other variations = true
Now how to write logic for having these results ? It looks simple but i think not enough.
An alternative to @Binary Worrier's solution:
bool Result = CaptchaIsValid OR NOT CaptchaIsExist
I think this expresses the logic more naturally, i.e. it conveys the intended logic when you read it.
Just specify the condition for false
and apply not
to it...
not (CaptchaIsExist && not (CaptchaIsValid))
No, it is really simple.
bool Result = not (CaptchaIsExist and not CaptchaIsValid)
(not CaptchaIsExist) or CaptchaIsValid
In C-like pseudocode:
if (CaptchaIsExist && !CaptchaIsValid) then
return false;
else
return true;
Boolean result = ((CaptchaIsExist && !CaptchaIsValid)) ? false: true;
精彩评论