I didn't understood the concept of the For-In loop in swift 3 , can anyone explain to us it m thanks in advance
var total = 0
for i in 0..<4 {
total += i
}
print(total)
The result of total is 6 , Why ?
i=0 => total = 0+0 =0
i=1 => total = 0+1 = 1
i=2 => total = 1+2 = 3
i=3 => total = 3+3 =6
it's simply alogrithm ;-)
i never reach 4 because you said it STRICTLY inferior to 4 =)
(Do I answer your question?)
printstatement in the loop and log the values oftotalandiat each iteration – that will show you what's happening.