Day 4 of #100DaysOfSwiftUI was all about looping and included while
, for
, repeat
. We then went within loops to apply continue
(to skip) and/or break
statements to exit. break
can be combined with labeling the outermost loop to ensure we exit both loops like so:
outermost: for i in 1...10 {
for j in 1...10 {
let total = i * j
print("\(i) * \(j) = \(total)")
if total == 100 {
print("That's enough!")
break outermost
}
}
}