What is the output?
var sum = 0
for i in 1...4 {
sum += i
}
print(sum)
for i in 2..<5 {
print(i, terminator: " ")
}
Try it in the online Swift Playground →
[spoiler title="Solution"]
Answer:
10 2 3 4
Explanation:
Closed ranges include endpoints; half-open exclude the upper bound.
[/spoiler]