Programming in Swift: Functions & Types

Jan 4 2022 · Swift 5.5, iOS 15, Xcode 13

Part 2: Closures

09. Introduction

Episode complete

Play next episode

Next
About this episode

Leave a rating/review

See forum comments
Cinema mode Mark complete Download course materials
Previous episode: Part 1 Quiz: Functions Next episode: 10. Closures

Get immediate access to this and 4,000+ other videos and books.

Take your career further with a Kodeco Personal Plan. With unlimited access to over 40+ books and 4,000+ professional videos in a single subscription, it's simply the best investment you can make in your development career.

Learn more Already a subscriber? Sign in.

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.

Transcript: 09. Introduction

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!