Line At A Time
Lesson 7: Booleans
Booleans Create a true/false value.
1let isSunny = true
2print(isSunny)
Terminal
$ swift main.swift
true
Every line, explained
let isSunny = true
A boolean (Swift calls the type Bool) can only be true or false, both lowercase. Swift names use camelCase: first word lowercase, every new word starting with a capital, like isSunny or highScore.
print(isSunny)
print(...) shows whatever is inside its round brackets in the terminal, then moves to a new line. All lowercase, both brackets needed, and no semicolon at the end; Swift doesn't use them. Printing a boolean shows the word true or false.