1.1 Booleans

  • signify true | false only
  • names should start with is/has (ie. isHungry)
// declaration - create but don't initialize<br>
var isOrange: Bool<br>
<br>
// create and initialize with an initial value<br>
var isApple = true<br>
<br>
// determine equality and assign value to constant -> false<br>
let guess = "dog"<br>
let dogEqualsCat = guess == "cat"<br>
<br>
// -> false<br>
let myAge = 30<br>
let isTeenager = myAge >= 13 && myAge <= 19<br>
<br>
// toggle a state change -> false<br>
var switchState = true<br>
switchState.toggle()