Not operation

Learn how to negate a boolean value.

The logical not operation inverts a boolean value. It is typically used to invert a condition or negate the result of an expression.

A negation is denoted by the ! sign before an expression:

!/*<value>*/
Try in Playground

Here is a practical example:

!true // false
Try in Playground

You can also use not for a more readable alternative:

not /*<value>*/
Try in Playground

In the above examples, the boolean value true is negated, resulting in false, as the following expression attests:

not true is false
Try in Playground