6
Functions and Closures
At this point, you can write reasonably complex programs that can make decisions and repeat instruction sequences. You can also store data for your programs using collection types. As the programs you write grow in size and complexity, it will become harder to comprehend what they do.
To make large programs easier to understand, Swift allows you to create functions, which let you combine several instructions together and execute them by calling a single name. You can also create closures, which let you combine several instructions together without a name and assign them to a constant or variable.
By the end of this chapter, you’ll have learned about functions, nested functions, functions as return types, functions as ...
Get iOS 17 Programming for Beginners - Eighth 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.