我有两个随机出现的值,我需要写一个条件来设置一个布尔值。
if(a == 1 && b == 1) then set both true
if(a == 1 && b == 0) then a as true and b as false
if(a == 0 && b == 1) then b as true and a as false
if(a == 0 && b == 0) then set both false
这种情况很好 我的问题是,我们有更好的方法/逻辑吗?
答案 0 :(得分:3)
这就像直接分配布尔测试一样简单:
a = (a==1)
b = (b==1)