closures

Throughout this series we’ve used Swift to build various models. As noted, one can build complex structures using common object-oriented (OO) techniques. As such, Swift is also known as a functional programming language. This idea extends the traditional OO paradigm with the notion that functions can act as types

The idea that functions can act as types has numerous benefits. As with most functions, the idea of using a String, Int or Bool to pass data is common. Swift extends this idea - allowing functions to be used as variables, parameters and return types. In this chapter, we’ll review how closures work and will discuss how to use them with algorithms.