UPGRADE YOUR SKILLS: Learn advanced Swift and SwiftUI on Hacking with Swift+! >>

DAY 8

Functions, part 2


Today you’re going to learn about handling errors in functions. That might sound awfully pessimistic, but as John Lennon said “life is what happens when you’re busy making other plans” – no one wants problems, but life has a habit of finding them anyway!

Fortunately, Swift makes error handling straightforward and somewhat foolproof: it requires that we handle errors, or at least acknowledge that they might happen. If you don’t at least attempt to handle errors well, your code simply won’t compile.

Today you have two tutorials to work through, in which you’ll meet default values for parameters and throwing functions, and then we’ll summarize functions and look at checkpoint 4. Once you’ve completed each video, there is a short piece of optional extra reading if you’re looking to get some more details, and there’s also a short test to help make sure you’ve understood what was taught.

  1. How to provide default values for parameters
  2. How to handle errors in functions
  3. Summary: Functions
  4. Checkpoint 4

Share your progress!

If you use Twitter, the button below will prepare a tweet saying you completed today, along with a celebratory graphic, the URL to this page, and the challenge hashtag. Don't worry – it won't be sent until you confirm on Twitter!

Need help? Tweet me @twostraws!

 

Hacking with Swift is sponsored by RevenueCat.

SPONSORED Take the pain out of configuring and testing your paywalls. RevenueCat's Paywalls allow you to remotely configure your entire paywall view without any code changes or app updates.

Click to save your free spot now

Sponsor Hacking with Swift and reach the world's largest Swift community!

100 Days of SwiftUI


The 100 Days of SwiftUI is a free collection of videos, tutorials, tests, and more to help you learn SwiftUI faster. Click here to learn more, or watch the video below.

Back to 100 Days of SwiftUI

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.