Chapter 13. Closures
Closures are discrete bundles of functionality that can be used in your application to accomplish specific tasks. Functions, which you learned about in the last chapter, are a special case of closures. You can think of a function as a named closure. Because functions are technically closures, Swift programmers sometimes use the two words interchangeably, despite the subtle distinction.
In Chapter 12, Functions, you worked primarily with global and nested functions. (Global functions are not defined on any specific type, and for this reason they are also called free functions.)
Closures differ from functions in that they have a more compact and lightweight syntax. They allow you to write a “function-like” construct without ...
Get Swift Programming: The Big Nerd Ranch Guide, 3rd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.