BLACK FRIDAY: Save 50% on all 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, and this will really be apparent as you work through today’s lessons. 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 to give your memory a little nudge.

As a reminder, SwiftUI uses closures extensively so it’s worth taking the time to really understand what’s going on here. Yes, they are probably the most complex feature of Swift, but it’s a bit like cycling up a hill – once you’ve reached the top, once you’ve mastered closures, it’s all gets much easier.

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.

  1. Using closures as parameters when they accept parameters
  2. Using closures as parameters when they return values
  3. Shorthand parameter names
  4. Closures with multiple parameters
  5. Returning closures from functions
  6. Capturing values
  7. 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 Black Friday sale.

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

Link copied to your pasteboard.