We introduce how to specify function types in Swift. We then go through some examples of how this might be used in Swift and a few pitfalls.
- [Instructor] As I mentioned before,…functional programming's treatment of functions…as first-class citizens means that we can treat functions…in a very similar way to other types,…such as strings, numbers, or objects.…The first thing we're going to look at…is an alternative way of defining functions.…In Swift, the way most of us are probably used to…defining functions is using the func keyword.…And the fact is that this is a perfectly fine way to do it.…But there's also another way that we can define functions,…and it has a syntax that's more similar…to the way we define variables and constants.…So when we define a constant such as a string or an integer,…the basic syntax looks like this,…where the type that we put after the colon,…in this case string or int,…denotes the type of our variables.…
We can also define a function in this way,…but if we do so, what does the type look like?…Well, to answer this, we need to ask ourselves,…what types of arguments the function takes,…and what its return type is.…If, for example, our function is going to take…
- 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.