# Programming in Swift: Functions & Types

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

## Part 2: Closures

### Episode complete

Play next episode

Next

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.

#### Notes: 10. 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’re accessing parts of this content for free, with some sections shown as obfuscated text.

Heads up... You’re accessing parts of this content for free, with some sections shown as obfuscated text.

Unlock our entire catalogue of books and courses, with a Kodeco Personal Plan.

Unlock now

As I said, closures and functions are really just different flavors of the same thing. Actually, technically, functions are a special type of closure!

operate(7, 3)
var addClosure😺: (Int, Int) -> Int

}
var addClosure: Operate = { 😺(a: Int, b: Int)
var addClosure: Operate = { (a: Int, b: Int) 😺-> Int
var addClosure: Operate = { (a: Int, b: Int) -> Int 😺in
return a + b
❌return❌ a + b
var addClosure = { (😺num1 a: Int, 😺num2 b: Int) -> Int in
var addClosure = { (a: Int, b: Int😺 = 10🛑) -> Int in
printResult(operate, 4, 5)
printResult(+, 4, 5)
printResult(operate: (Int, Int) -> Int, a: Int, b: Int)
printResult(
{

}...
(a: Int, b: Int)
(a: Int, b: Int) 😺-> Int
(a: Int, b: Int) -> Int 😺in
a * b  + 100
a * b + 100
},
3, 10
)