not
The not keyword is the logical NOT operator. It negates a Boolean operand, returning true when the operand is falsy and false when it is truthy.
Syntax & Example
let done = false;
if not done {
print("still working");
}
let isEmpty = not items.any();
Use Cases
- Inverting a Boolean condition.
- Expressing negative guards readably (
if not valid). - Combining with
and/orto build compound expressions.