开发者

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;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜