O'Reilly logo

Swift 3 ObjectOriented Programming - Second Edition by Gastón C. Hillar

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Understanding functions as first-class citizens

Since its first release, Swift has been a multiparadigm programming language, and one of its supported programming paradigms is functional programming. Functional programming favors immutable data and, therefore, avoids state changes. The code written with a functional programming style is as declarative as possible, and it is focused on what it does instead of how it must do it.

As it happens in many modern programming languages, functions are first-class citizens in Swift 3. You can use functions as arguments for other functions or methods. We can easily understand this concept with a simple example: array filtering. However, take into account that we will start by writing imperative code with functions ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required