You’ve made it to the end of the fourth part of this series, so let’s summarize:
for
, which assigns each item inside the loop to a temporary constant.for
loops give you, use an underscore instead so Swift can skip that work.while
loops, which you provide with an explicit condition to check.while
loops, repeat
loops always run the body of their loop at least once.break
, but if you have nested loops you need to use break
followed by whatever label you placed before your outer loop.continue
.while true
. Make sure you have a condition somewhere to end your infinite loops!SPONSORED Play is the first native iOS design tool created for designers and engineers. You can install Play for iOS and iPad today and sign up to check out the Beta of our macOS app with SwiftUI code export. We're also hiring engineers!
Sponsor Hacking with Swift and reach the world's largest Swift community!
Link copied to your pasteboard.