This module covers the three Swift features you'll lean on in every app you write: functions to package up reusable code, closures to pass behavior around, and optionals to handle values that might be missing.
You'll learn how to define and call functions with parameters and return values, then see how closures work as unnamed functions you can store in variables and hand to other functions. Finally, you'll learn how Swift's optionals keep your code safe from crashes, and how to unwrap them properly.
Each topic has two different explanations, so if one doesn't click the other might. Every clip is cut to just the relevant chapter of a longer course. When you're ready, continue on to Structs, Classes & Protocols.
Define and call functions, pass parameters, return values, and reuse code instead of repeating it.
A second, shorter walkthrough of defining and using functions.
What closures are, how to store them in variables, and how to pass them to other functions.
A quick second take on closure syntax and how closures are used in practice.
Why Swift has optionals, what nil means, and how to unwrap values safely.
An extended look at optionals and the different ways to unwrap them.