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!
SPONSORED Are you tired of wasting time debugging your Swift app? Instabug’s SDK is here to help you minimize debugging time by providing you with complete device details, network logs, and reproduction steps with every bug report. All data is attached automatically, and it only takes a line of code to setup. Start your free trial now and get 3 months off exclusively for the Hacking with Swift Community.
Link copied to your pasteboard.