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.
forloops give you, use an underscore instead so Swift can skip that work.
whileloops, which you provide with an explicit condition to check.
repeatloops always run the body of their loop at least once.
break, but if you have nested loops you need to use
breakfollowed by whatever label you placed before your outer loop.
while true. Make sure you have a condition somewhere to end your infinite loops!
UPGRADE YOUR SWIFT Hacking with Swift Live is a new iOS conference taking place in the UK this July, with all profits going to charity. Come and learn the major new APIs announced at WWDC19 with sessions and hands-on tutorials – click here to learn more!