require 'test/unit'
class NotTest < Test::Unit::TestCase
def test_quirky_little_bastard_not
assert 1
assert_equal false, !1
assert_equal false, (not 1)
assert (1 && 2), (1 and 2)
assert_equal (not 1 && 2), !(1 && 2)
assert_equal false, (not 1 && nil) == (!1 and nil)
assert_equal (not 1 && nil), (!(1 and nil))
end
end
Quirky little bastard that one, I think the only intuitive approach to this is ... given the list of operator precedence:
!
&&
||
not
or
and
The though could have been not to mix and match hardcore operators (&, !, blah) with English (and, not, blah)
"I can assure you he's a better man than me,
So fuck you, don't tell me."
Dry Kill Logic - Better Man Than Me.
0 Responses to Ruby operator precedence is slightly not intuitive
Something to say?