NEW: Start my new Ultimate Portfolio App course with a free Hacking with Swift+ trial! >>

DAY 4

Loops


Loops are one of the things that make computers so utterly brilliant: the ability to repeat some simple task billions of times every second.

Of course, what goes in those loops is down to you: you might be adding some numbers, you might be reading some sensor data, or you might be redrawing the screen 120 times a second. As Craig Bruce said, “it’s hardware that makes a machine fast, but it’s software that makes a fast machine slow.”

The point is that they allow us to take some simple job – “blow out a candle”, for example – and repeat it a number of times. So rather than writing the code “blow out a candle then blow out a candle then blow out a candle then…”, which would be rather boring if you were celebrating a 75th birthday, you instead say “for each candle on the cake, blow out the candle” and the computer takes care of the rest.

Today you have eight one-minute videos to watch, and you’ll meet things like for loops, infinite loops, and more. Once you’ve watched each video and gone through any optional extra reading that interested you, there’s a short test to help make sure you’ve understood what was taught.

  1. For loops
  2. While loops
  3. Repeat loops
  4. Exiting loops
  5. Exiting multiple loops
  6. Skipping items
  7. Infinite loops
  8. Looping summary

Have some questions about loops?

Hit Send below to start a virtual conversation with me.

Need help? Tweet me @twostraws!

 

Hacking with Swift is sponsored by RevenueCat

SPONSORED Building and maintaining in-app subscription infrastructure is hard. Luckily there's a better way. With RevenueCat, you can implement subscriptions for your app in hours, not months, so you can get back to building your app.

Try it for free

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.