/*
for 루프상수 in 순회대상 {
// 실행할 구문
}
*/
// 범위
for i in 1...4 {
print(i) // 1, 2, 3, 4
}
// Array
let array = [1,2,3,4,5]
for i in array {
print(i)
}
/*
while 조건식 {
// 실행할 구문
}
*/
// 조건식이 true일 때 계속 실행
var number = 5
while number < 10 {
number += 1
}
number // 10
/*
repeat {
// 실행할 구문
} while 조건식
*/
// while과 비슷하지만 repeat에 있는 구문을 반드시 실행한 후 while
var x = 0
repeat {
x += 2
} while x < 5
print(x) // 6