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]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]import Swift@frozen struct BoolA value type whose instances are either true or false.
init() Creates an instance initialized to false.
init(_ value: Bool) Creates an instance equal to the given Boolean value.
init?(_ description: String) Creates a new Boolean value from the given string.
init(booleanLiteral value: Bool) Creates an instance initialized to the specified Boolean literal.
init(from decoder: any Decoder) throws static func random() -> Bool Returns a random Boolean value.
static func random<T>(using generator: inout T) -> Bool where T : RandomNumberGenerator Returns a random Boolean value, using the given generator as a source for randomness.
var customMirror: Mirror { get }A mirror that reflects the Bool instance.
var description: String { get }A textual representation of the Boolean value.
static func ! (a: Bool) -> Bool Performs a logical NOT operation on a Boolean value.
static func && (lhs: Bool, rhs: @autoclosure () throws -> Bool) rethrows -> Bool Performs a logical AND operation on two Boolean values.
static func == (lhs: Bool, rhs: Bool) -> Bool static func || (lhs: Bool, rhs: @autoclosure () throws -> Bool) rethrows -> Bool Performs a logical OR operation on two Boolean values.
func encode(to encoder: any Encoder) throws Encodes this value into the given encoder.
func hash(into hasher: inout Hasher) Hashes the essential components of this value by feeding them into the given hasher.
var customPlaygroundQuickLook: _PlaygroundQuickLook { get }A custom playground Quick Look for the Bool instance.