Negate a Bool with the prefix operator

suggest change

The prefix \! operator returns the logical negation of its argument. That is, !true returns false, and !false returns true.

print(!true)  // prints "false"
print(!false) // prints "true"

func test(_ someBoolean: Bool) {
    if !someBoolean {
        print("someBoolean is false")
    }
}

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents