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!SAVE 50% To celebrate Black Friday, 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.
Sponsor Hacking with Swift and reach the world's largest Swift community!
Link copied to your pasteboard.