Leave a rating/review
Notes: 09. Introduction
Update Notes: This course was originally recorded in 2019. It has been reviewed and all content and materials updated as of October 2021.
In this part of the course, we’re going to take a close look at Swift closures. You actually already know a little bit about closures, for a couple of reasons:
First, you’ve probably already used closures! You needed them when you created buttons in both your first and second SwiftUI apps! We’ll take another look at those examples a little later.
Second, you’re familiar with functions! Closures and functions are really just different flavors of the same thing. They’re blocks of code that do something.
You can call closures like functions, you can store them in variables or constants, and use them in higher-order functions.
In this part, we’ll take some time to study the differences and similarities between functions and closures.
And you’ll get plenty of practice with closure syntax. We’ll cover the plethora of options that can make closures harder to read, if you’re not used to looking at them.
We’ll also go over several methods on collections, like arrays and dictionaries, that have closure parameters.
We’ll write closures to do things like filter collections for specific criteria, transform an array of one type into another type, and weed out nil values from collections of optionals! Meet me in the next episode to get started with closures!