WWDC23 SALE: Save 50% on all my Swift books and bundles! >>

DAY 7

Closures, part two


Yesterday you learned the basics of closures, but today things get a little trickier. But that’s OK: Benjamin Franklin once said, “energy and persistence conquer all things” – you can do this!

Sometimes closure syntax can be a bit hard on your eyes. If you find it a bit overwhelming – if you’re staring at some code and aren’t 100% sure of what it means – just go back one video and watch it again.

Today you have seven one-minute videos to watch, and you’ll learn about how closures accept parameters and return values. Once you’ve completed each video you can go over any optional reading if you need it, then take a short test to help make sure you’ve understood what was taught.

To make things a little less intimidating, I’ve split up today’s topics into two sections: the least you need to know to continue, and more advanced topics that will really develop your learning. Keep in mind that I’ve already said closures are hard, so I hope you can appreciate that more advanced closures are doubly hard – don’t feel bad if you try the more advanced topics and think you’ve had enough and want to move on!

The least you need to know

  1. Using closures as parameters when they accept parameters
  2. Using closures as parameters when they return values
  3. Shorthand parameter names

If you make it through those, you’re most of the way to understanding how closures are used in Swift and why they are important. However, if you want to see more advanced usages of closures you’re welcome to press on!

Advanced closures

  1. Closures with multiple parameters
  2. Returning closures from functions
  3. Capturing values
  4. Closures summary

Remember, stay accountable: tell the world that you’ve just learned all about closures in Swift, and discuss them with others who are learning too.

Need help? Tweet me @twostraws!

 

Save 50% in my WWDC23 sale.

SAVE 50% To celebrate WWDC23, all our books and bundles are half price, so you can take your Swift knowledge further without spending big! Get the Swift Power Pack to build your iOS career faster, get the Swift Platform Pack to builds apps for macOS, watchOS, and beyond, or get the Swift Plus Pack to learn advanced design patterns, testing skills, and more.

Save 50% on all our books and bundles!

100 Days of Swift


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

Back to 100 Days of Swift

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.