1.1 Booleans

  • signify true | false only
  • names should start with is/has (ie. isHungry)
// declaration - create but don't initialize
var isOrange: Bool

// create and initialize with an initial value
var isApple = true

// determine equality and assign value to constant -> false
let guess = "dog"
let dogEqualsCat = guess == "cat"

// -> false
let myAge = 30
let isTeenager = myAge >= 13 && myAge <= 19

// toggle a state change -> false
var switchState = true
switchState.toggle()