unary operators
Syntax
not <operand>
- <operand>
not true
not false
not bookIsHardcover()
-numericVariable
-5
- myDebt()
Explanation
not
The not
operator reverses a boolean. So if operand evaluates to true
, not
gives you false
,
if operand evaluates to false
, not
turns it into true
.
negation
The -
operator flips the sign on a number. E.g. if you use it with the number 5
,
or a variable containing that number, it will turn it into -5
. If you use it with e.g.
-66
, it will turn it into 66
.