Day 6

100 Days of SwiftUI

What is a Closure? Straight from the Swift documentation on Closures.

Closures are self-contained blocks of functionality that can be passed around and used in your code. Closures in Swift are similar to blocks in C and Objective-C and to lambdas in other programming languages.

Closures can capture and store references to any constants and variables from the context in which they are defined. This is known as closing over those constants and variables. Swift handles all of the memory management of capturing for you.

Closures are very common in iOS development. The truth is that you’ve probably used closures without realizing it.