Instance Method

toggle()

Toggles the Boolean variable’s value.

Declaration

mutating func toggle()

Discussion

Use this method to toggle a Boolean value from true to false or from false to true.

var bools = [true, false]

bools[0].toggle()
// bools == [false, false]

See Also

Transforming a Boolean

static func ! (Bool) -> Bool

Performs a logical NOT operation on a Boolean value.

static func || (Bool, () -> Bool) -> Bool

Performs a logical OR operation on two Boolean values.

static func && (Bool, () -> Bool) -> Bool

Performs a logical AND operation on two Boolean values.