Negate a Bool with the prefix operator
suggest changeThe 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")
}
}
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents