Reputation: 34053
Ruby has the conditional unless
.
Does it have nor
?
E.g.
unless 1 == 2 nor 1 == 3
"nothing equal"
else
"something's equal"
end
Upvotes: 0
Views: 1139
Reputation: 143194
Ruby doesn't have a built-in nor, but you could extend the built-in booleans like so:
class TrueClass
def nor(other)
false
end
end
class FalseClass
def nor(other)
!other
end
end
and then write
unless (1 == 2).nor(1 == 3)
"nothing equal"
else
"something's equal"
end
Upvotes: 3
Reputation: 794
Nope... but you can simulate it like this:
unless 1 != 2 && 1 != 3
"nothing equal"
else
"something's equal"
end
Upvotes: 1