*Close range: let closedRange = 0...5
Half-open range: let halfOpenRange = 0..<5
*
let count = 10 var sum = 0 for var i = 1; i <= count; i++ { sum += i } |
let count = 10 var sum = 0 for i in 1...count { sum += i } |
For loop
var sum = 1 while sum < 1000 { sum = sum + (sum + 1) }
While loop
*
var sum = 0 rowLoop: for row in 0..<8 { columnLoop: for column in 0..<8 { if row == column { continue rowLoop } sum += row * column } }
This code block makes use of labeled statements, labeling the two loops as the rowLoop and the columnLoop, respectively. When the row equals the column inside the inner columnLoop, the outer rowLoop will continue.