Programming in Swift: Functions & Types

Jan 4 2022 Swift 5.5, iOS 15, Xcode 13

Part 2: Closures

16. Challenge: Closures & Collections

Lesson Complete

Play Next Lesson
Save for later
About this episode
See versions

See course reviews

See forum comments
Cinema mode Mark as Complete Download course materials
Previous episode: 15. compactMap & flatMap Next episode: 17. filter, reduce, & sort

Update Notes: This course was originally recorded in 2019. It has been reviewed and all content and materials updated as of October 2021.

Heads up... You've reached locked video content where the transcript will be shown as obfuscated text.

You can unlock the rest of this video course, and our entire catalogue of books and videos, with a Professional subscription.

I’ve got another challenge for you! This time you’ll try out using forEach, map, compactMap, and flatMap on your own.

students.forEach { (<#Student#>) in
students.forEach { (student) in
let classLibraryBooks = 
let classLibraryBooks = { (<#Student#>) -> T in
} { (student)
-> [String]
let classPets = 
students.compactMap {...
{ (student) -> String? in
{ ❌(student) -> String? in❌
classLibraryBooks.flatMap { $0 }
let classLibraryBooks = { (student) -> [String] in
let classLibraryBooks = students.flatMap