The negation operator
RomanMenzel opened this issue · comments
Roman Menzel commented
When I try to use the negation operator without parens, it doesn't work!
With which ruby version did you try the examples?
Jordan Harband commented
Can you provide a code example? x = 3; -x
prints out negative three in every ruby console I've ever used.
Roman Menzel commented
No, I mean the '!' operator. An example would be:
if !x == 3
...
end
This doesn't work! ☝️
Jordan Harband commented
You want if x != 3
there. negation applies to a value, and !x
will never == 3, because !x
will always be a boolean true
or false
.
Roman Menzel commented
Ok, now I understand, thank you.