We discuss how Swift's treatment of functions as first-class citizens allows us to pass functions as arguments to other functions, and then show some examples of how this is done.
- [Instructor] Now that we've seen…how we can define functions in the…same way that we can define other types,…the next step is to look at how…we can pass functions as arguments to other functions.…When we create a function that takes…other things such as strings or integers…as arguments, we have to specify the argument types…in the function definition like this.…If we have a function that takes…a string and prints it uppercased, it will look like this.…Function print uppercased.…Takes a string as an argument.…String.…Doesn't return anything.…And inside the function we say print…string dot uppercased.…
Parentheses.…Then we call this function like this.…Print uppercased.…String.…Hello.…So we're used to passing an argument…with the purpose of specifying what the data…is that we're operating on, but what if…instead of passing arguments into…our function to specify what our data is,…we could pass an argument to specify…what was done to our data?…This is one of the important things…that first class functions lets us do…and we'll look at some examples in a bit.…
- What is functional programming?
- Keeping functions and data separate
- First-class functions
- Working with arrays functionally
- Filtering and reducing
- Partial-application and recursion
Skill Level Intermediate
Swift 4: Protocol-Oriented Programmingwith Károly Nyisztor1h 44m Intermediate
Swift: Delegations and Data Sourceswith Steven Lipton1h 6m Intermediate
Swift: Writing Reusable Frameworkswith David Okun1h 49m Intermediate
1. What Is Functional Programming?
2. First-Class Functions
3. Array Functions
4. Advanced Functional Concepts
Next steps1m 1s
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.