April 2026
Intermediate
683 pages
25h 29m
English
Although we took a sneak peek at strings (text) and integers (numbers) previously, we’ll mark your official entry into Swift data types by introducing the most basic type of them all: Booleans. Following that, we’ll cruise toward more advanced types.
Boolean data types exist in nearly all programming languages. It is a black-or-white kind of data type: It can be either true or false. This also represents one of the most fundamental concepts of human logic: Some statements are either correct or incorrect.
Listing 2.11 demonstrates how to declare Boolean variables and directly assign values to them.
var swiftIsEasy: Bool = truevar catsCanFly: Bool = falsevar birdsCanFly: BoolbirdsCanFly = true
Listing 2.11 ...
Read now
Unlock full access