我试图检查是否case1
和或case2
并想出了以下代码
if(case1 && || case2)..
但这似乎不起作用,甚至可以像这样使用两个运算符吗?如果没有,是否有任何解决方法?
No. Either both case1 AND
case2 must be true OR
one of them.
if (case1 || case2) {....}
||
is "and/or" already. You'd need to work to get "exclusive or" (a.k.a. XOR).
AND/OR is the same as OR. You want case1 || case2
:
case1 case2 case1 and case2 case1 or case2 case1 and/or case2
0 0 0 0 0
0 1 0 1 1
1 0 0 1 1
1 1 1 1 1
As you can see, this is simply an OR.
True OR true is true, that's just how OR works. See http://en.wikipedia.org/wiki/Logical_disjunction.
There's no such thing as an "AND/OR". It sounds like perhaps you were confusing OR with exclusive-OR.
it wont work and you dont need this either.
There are three conditions:
For condition 1 &&
operator
For condition 2 ||
operator
for condition 3 ~
of 2 condition. As all are mutual excusive you don't need what you have said.