Programming in Swift: Functions and Types
Dec 3 2019 · Video Course (4 hrs, 25 mins) · Beginner
Gain a deeper understanding of functions, practice using closures, and build your skills with named types.
Version
- Swift 5.1, Xcode 11


Functions
Find out what you'll learn in this course, what you should know already, and how to get the most out of it.
Review Functions
2:23Before you move on to some more advanced features of functions, review what you should already know.
Challenge: Functions
4:03Practice what you have learned about writing functions so far with this open-ended coding challenge.
Overloading
8:05When you create multiple functions with the same name, it's called "Overloading". Find out the rules to overloading functions.
Advanced Parameters
4:41Learn how to add variadic parameters to functions and how to use the inout keyword to mutate parameters in a function.
Practice what you have learned about function overloads and parameters with this series of hands-on coding challenges.
Functions are really just another type of data in Swift! You can use them as parameters for other functions.
Conclusion
0:26Review what you learned about functions in this part of the course, and see what is coming up in the next part.
Closures
Introduction
1:13In this part of the course you'll learn about Swift closures, and how they can help you deal with collections.
Closures
7:52See what closures and functions have in common, and find out about some key differences between the two.
Challenge: Closures
3:21Practice what you have learned about writing closures with this series of hands-on coding challenges.
Closure Syntax
9:43Closures coming with a dizzying arraying of syntactical options! Learn how to read and write them all in this episode.
Practice writing closures using different levels of verbosity with this series of hands-on coding challenges.
forEach & map
6:40Find out how writing closures can help you handle collections with two common alternatives to for loops: forEach and map!
compactMap & flatMap
6:01Try out two specialized mapping methods that help you deal with collections of optionals and multidimensional collections!
Practice what you have learned about using closures and collection with this series of hands-on coding challenges.
filter, reduce, & sort
12:36Learn to use three more methods to help you filter and sort collections, and use all elements in a collection with reduce.
Practice what you have learned about filter, reduce, and sort with this series of hands-on coding challenges.
Conclusion
3:57Review what you learned about closures and how they can help you with collection, and see what is coming up in the next part.
Enumerations
Introduction
1:22In this part of the course you'll learn what enumerations are, and how they can work together with switch statements.
Enumerations
8:26Learn how to use enumerations to represent a specific set of related, discrete values like card suits or seasons.
Practice what you have learned about using enumerations with this series of hands-on coding challenges.
Switch Statements
7:02Switch statements are another method of control flow like loops and if statements. Find out how they can help you deal with enumerations.
More Switch Statements
12:14You can use switch statements to switch on types other than enumerations! Try it out in this episode.
Practice what you have learned about switch statements with this series of hands-on coding challenges.
Associated Values
6:52There’s another way to associate values with your enumeration instances. They are literally called “associated values”.
Conclusion
0:33Review what you learned about enumerations and switch statements, and see what is coming up in the next part.
Properties & Methods
Introduction
0:49In this part of the course, you'll study some features shared by named types: properties and methods!
Stored Properties
9:33Learn more about stored properties, like how to use property observers, getters and setters, and type properties.
Computed Properties
7:00In this episode, learn about a different kind of property that is recomputed every time it is accessed!
Lazy Properties
4:04In this episode, learn about the lazy keyword and how it can help you avoid expensive calculations until you need them.
Practice what you have learned about using different kinds of properties with this series of hands-on coding challenges.
Methods
13:43Take a deep dive into methods, including writing initializers, mutating methods, and more. Work with structures and enumerations!
Challenge: Methods
4:28Practice what you have learned about using methods through this series of hands-on coding challenges.
In this episode, Learn when it is best to use computed properties, and when it's best to use methods.
Conclusion
0:55Review what you learned about properties and methods in this part of the course, and find out what's up next.
Protocols & Inheritance
Introduction
1:30In this part of the course, learn how you can use subclassing and protocol adoption to let your types inherit functionality.
Inheritance
15:05Learn about a unique features of Swift classes that lets one class inherit functionality from another class.
Practice what you've learned about subclassing with these hands-on challenges about Swift class inheritance.
Initializers
13:26Learn how to create your own class initializers, including two-phase initialization, and required vs. convenience initializers.
Practice what you've learned about initializers by creating your own class initializers, with some hands-on challenges.
Protocols
6:41Learn how to make your types conform to protocols in Swift, which you can think of as a to-do list for your types.
Swift extensions can help you add functionality to named types, and give your protocols more power with default implementations!
Challenge: Protocols
6:08Practice what you have learned about protocols and extensions in this series of hands-on challenges.
Review the differences between classes and structures in Swift, and when you might want to subclass or use a protocol.
Conclusion
1:08You've learned a ton of new Swift concepts! Find out where to go next with all of your new knowledge.
Who is this for?
This course is part of our iOS and Swift for Beginners learning path. You're ready for this course if you're working through that learning path in order, or you're someone who has just a little bit of Swift experience.
To start, you'll review some function fundamentals and learn more advanced features of functions. You'll also practice writing closures, a close relative of functions, and using them to manipulate collections.
Then, you'll move on to build your skills in writing named types: structures, classes, enumerations, and protocols. You'll learn about the features they share, and some of the functionality that makes each unique.
Throughout the course, you'll practice everything you learn with hands-on challenges.
This course isn’t suited for advanced developers. If that’s you, check out our Advanced Swift Courses for more ways to level-up your Swift skills!
Covered concepts
- Functions
- Overloading
- Closures
- Higher-Order Functions
- Enumerations
- Switch Statements
- Getters and Setters
- Property Observers
- Computed Properties
- Lazy Variables
- Methods
- Subclassing
- Initializers
- Protocols
- Extensions
Comments