From the course: Learning Higher-Order Functions with Swift
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Higher-order functions
From the course: Learning Higher-Order Functions with Swift
Higher-order functions
- [Instructor] So what is a higher-order function? Kind of an intimidating name, higher-order functions. Well, a higher-order function is really just a function that takes one or more closure/functions as a parameter and/or returns a closure/function. So all it has to do is take or return a closure because we know a function is just a named closure. So, technically, we've already made one. Congratulations. Our example was a higher-order function. It might be a bad example, but it's the concept. And that's what we're trying to focus on now. It's not the most difficult version but an understandable one. So let's look again at it. So we've got this typealias CombinesToStrings. It takes a string and a net returns a string. So our usesStingFactor takes that closure, CombinesToStrings. So it's higher-order function. It takes that, and we can pass in anything that matches that type. Any type of closure. We were doing it with a function. We were also doing it with a variable or constant named…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.