Swift Language Booleans What is Bool?

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Extensions
> Step 2: And Like the video. BONUS: You can also share it!

Example

Bool is a Boolean type with two possible values: true and false.

let aTrueBool = true
let aFalseBool = false

Bools are used in control-flow statements as conditions. The if statement uses a Boolean condition to determine which block of code to run:

func test(_ someBoolean: Bool) {
    if someBoolean {
        print("IT'S TRUE!")
    }
    else {
        print("IT'S FALSE!")
    }
}
test(aTrueBool)  // prints "IT'S TRUE!"


Got any Swift Language Question?