3 ms·
It doesn't really work quite as you suggest; it's just that a &! b == a & !b where !b is true if b is nil or false, and false otherwise. & works as a bit
by threedaymonk 14y ago
It doesn't really work quite as you suggest; it's just that
a &! b == a & !b
where !b is true if b is nil or false, and false otherwise.
& works as a bitwise AND for numbers, and a logical AND for boolean values. You can't mix the two, but as long as a is a boolean, you'll get some kind of result out of the calculation:
true &! true # => false
true &! false # => true
true &! 0 # => false
0 &! 0 # => TypeError: can't convert false into Integer