for in
let platforms = ["iOS", "macOS", "tvOS", "watchOS"] for os in platforms { print("Swift works great on \(os).") } |
Swift works great on iOS. Swift works great on macOS. Swift works great on tvOS. Swift works great on watchOS. |
// 5를 포함 for i in 1...5 { print("Counting from 1 through 5: \(i)") } // 5를 미포함 for i in 1..<5 { print("Counting 1 up to 5: \(i)") } |
Counting from 1 through 5: 1 Counting from 1 through 5: 2 Counting from 1 through 5: 3 Counting from 1 through 5: 4 Counting from 1 through 5: 5 Counting from 1 through 5: 1 Counting from 1 through 5: 2 Counting from 1 through 5: 3 Counting from 1 through 5: 4 |
for _ in 1...5 { } |
숫자를 포함하지 않고 5번 루프만... |