Chapter 3: Conditionals and Optionals

In the last chapter, you looked at data types, constants, variables, and operations. At this point, you are able to write simple programs that process letters and numbers. However, programs don't always proceed in sequence. Oftentimes, you will need to execute different instructions based on a condition. Swift allows you to do this by using conditionals, and you will learn how to use them in this chapter.

Another thing you may have noticed is that, in the last chapter, each variable or constant was immediately assigned a value. What if you require a variable where the value may not be present initially? You will need a way to create a variable that may or may not have a value. Swift allows you to do this ...

Get iOS 14 Programming for Beginners - Fifth Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.