Boolean: True or False


var a = true

Objects of Boolean type in Swift are called Bool and refer to the logical values true and false. A Boolean can only have the value of true or false, which are two Boolean constant values provided by Swift. Booleans are most commonly used with conditional statements like if and else if. Since Swift requires that conditional statements evaluate to a Bool value, it is common to see either a Boolean variable or constant used in an expression like a comparison since that results in a Bool.

var a = true
var b = 1
var c = 2

// the if statement below checks if the variable a
// is a Bool and if it has a value of true

if a {
    println("a is true")

/* the if statement below executes the conditional expression checking if b equals c which returns a Bool which is evaluated to determine if the resulting code is executed. */

if b == c{
    println("b = c")
    println("b != c")