
[Swift Language Guide] ์ ์ดํ๋ฆ(Control Flow)
Swift Language Guide
2023. 5. 24. 19:11
for๋ฌธ์ stride ๋ฉ์๋ for i in stride(from: 0, to: 10, by: 2) { print(i) // 0, 2, 4, 6, 8 } for i in stride(from: 0, through: 10, by: 2) { print(i) // 0, 2, 4, 6, 8, 10 } // reverseํ๊ณ ์ถ์ ๋ ์ธ ์ ์๋ค. for i in stride(from: 3, through: 0, by: -1) { print(i) // 3, 2, 1, 0 } 1์ฉ ์ฆ๊ฐ๊ฐ ์๋ ์ํ๋ ์ซ์๋งํผ ์ฆ๊ฐ ์ํค๊ณ ์ถ์ ๋ ์ฌ์ฉ to : toํ๋ผ๋ฏธํฐ์ ์๋ ์๋ฅผ ์ ์ธํ๋ค. through: throughํ๋ผ๋ฏธํฐ์ ์๋ ์ ํฌํจํ๋ค. repeat while ๊ตฌ๋ฌธ var num = 1 repeat { num +..