Explore different options to call throwing functions inside of other throwing functions, by handling errors internally or requiring the caller to handle them. See how to force try throwing functions when you're certain an error cannot occur.
- [Narrator] I'll keep going in the same exercise…file from the previous video.…When a function calls a throwing function in its…own body, there are two options.…The first is that the function can catch…and handle any errors thrown itself.…I'll define a do something function…that calls perform action and catches…and handles any errors it throws.…And now we'll call it, alternatively…a function that calls a throwing function…can also be marked as throwing function.…And when calling a throwing function in…its body just prepend that call with tri…but do not enclose that call in a do catch statement.…
What this does is push the air handling…for that throwing function or propagate…the error to the caller of the function.…A throwing function that returns a value…can also be called using an optional tri expression by…writing a question mark suffix on the tri keyword.…This will cause the return value to be an optional.…When calling a throwing function that you…know will not fail, you can use a forced…tri expression to disable error propagation…
Learn how to write code, understand Swift's key concepts and best practices, and strengthen your programming problem-solving skills. Instructor Scott Gardner teaches the fundamentals, so you'll be prepared to develop applications for iOS, macOS, and other platforms. Completing this course will enable you to not only write first-class code, but to think like a Swift developer.
- Creating playgrounds
- Defining variables and constants
- Working with characters and strings
- Working with collections and groups
- Using operators and defining custom operators
- Controlling program flow
- Defining functions and closures
- Working with classes, structures, and enumerations
- Adopting protocols
Skill Level Beginner
1. Get Started
2. Variables and Constants
3. Characters and Strings
4. Collections and Tuples
6. Control Flow
- 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.