Swift Booleans
Bool is true or false. Comparisons give booleans, and ! flips them. toggle() flips a variable in place.
Example
var on = true
print(on, !on, 5 > 3)
on.toggle()
print(on)Exercise
Flip a Bool.
on.()
Quiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.