From the course: Learning Functional Programming with Swift

Unlock the full course today

Join today to access over 22,500 courses taught by industry experts or purchase this course individually.

First-class functions

First-class functions - Swift Tutorial

From the course: Learning Functional Programming with Swift

Start my 1-month free trial

First-class functions

- [Instructor] The third major concept of functional programming is something called first-class functions. In object oriented programming, we generally treat variables and functions as entirely different entities. We would never think of, for example, assigning functions to variables or passing functions as arguments to other functions. In functional programming, however, we can treat functions in a very similar way to how we treat other values such as numbers and strings. This concept is what we mean when we talk about first-class functions. What this means is that we can assign functions to variables, pass them as arguments to functions, and even return them from other functions. As we'll see, this can give our programs tremendous flexibility. For example, this concept can allow us to combine existing functions to create new functions. We'll see in the next chapter how this is done and what its implications are for our programs.

Contents