Ruby有条件的unless
。
有nor
吗?
例如
unless 1 == 2 nor 1 == 3
"nothing equal"
else
"something's equal"
end
Ruby没有内置的,但是您可以像下面这样扩展内置的布尔值:
class TrueClass
def nor(other)
false
end
end
class FalseClass
def nor(other)
!other
end
end
然后写
unless (1 == 2).nor(1 == 3)
"nothing equal"
else
"something's equal"
end
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句