Programming in Swift: Functions & Types

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

Part 2: Closures

11. Challenge: Closures

Episode complete

Play next episode

About this episode

Leave a rating/review

See forum comments
Cinema mode Mark complete Download course materials
Previous episode: 10. Closures Next episode: 12. Closure Syntax

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: 11. Challenge: Closures

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.

I’ve got a quick challenge to help you practice writing closures. You’ll find it on page 3 of the Playground for this part of the course. Pause the video, give it a try, and then come back to go over some solutions. Have fun!

let fullName =
let fullName = {

let fullName = { 😺(firstName: String, lastName: String?) -> String🛑 
let fullName = { (firstName: String, lastName: String?) -> String 😺in 
  😺firstName + " " + (lastName ?? "")🛑
let ozmaName = calculateFullName(firstName: "Ozma", lastName: "Catterwaul")
let princeName = fullName("Prince", nil)
printResult({ (<#Double#>, <#Double#>) -> Double in
}, <#T##a: Double##Double#>, <#T##b: Double##Double#>)
  { (😺a, b🛑) -> Double in
    ((a * a) + (b * b)).squareRoot()
  { (a, b) -> Double in
    ((a * a) + (b * b)).squareRoot()
😺5, 3🛑