[Swift] for문 역방향 사용하기
10부터 0까지 숫자를 출력. for i in (0 ..< 10).reverse() { print("i = \(i)") } print("========================") for i in (0 ... 10).reverse() { print("i = \(i)") } print("========================") for i in 10.stride(through: 1, by: -1) { print("i = \(i)") } print("========================") for i in 10.stride(to: 0, by: -1) { print("i = \(i)") }