27. The Complement Operator
The exclamation (!) sign is used switch a value to its opposite boolean value. In boolean algebra1 this is referred to as a Not (or negation) operator.
| Operator |
|---|
! |
The following example makes sure that “not true” is the same as “false”:
assert !true == false
The complement operator results in the following:
| Value | Complement |
|---|---|
true |
false |
false |
true |