Chapter 7
Making Decisions with Branches
After a program receives data, it needs to manipulate that data somehow to return a useful result. Simple programs manipulate data the same way, but more complicated programs need to make decisions on how to manipulate that data.
For example, a program might ask the user for a password. If the user types in a valid password, then the program gives the user access. If the user does not type in a valid password, then the program must display an error message and block access.
When a program analyzes data and makes a decision based on that data, it uses something called Boolean values and branching statements.
Boolean values represent either a true or false value. Branching statements give your program ...
Get Swift OS X Programming for Absolute Beginners now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.