Instance Methodswift 6.2.4Swift

toggle

Toggles the Boolean variable’s value.

mutating func toggle()

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]