Operator: prefix !

operator prefix ! { associativity precedence }

Declarations

prefix func !(_: Bool)

Performs a logical NOT operation on a Boolean value.

The logical NOT operator (!) inverts a Boolean value. If the value is true, the result of the operation is false; if the value is false, the result is true.

var printedMessage = false

if !printedMessage {
    print("You look nice today!")
    printedMessage = true
}
// Prints "You look nice today!"

a: The Boolean value to negate.

Declaration

prefix func !(a: Bool) -> Bool