Notice
Recent Posts
Recent Comments
Link
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | 2 | 3 | 4 | 5 | 6 | |
| 7 | 8 | 9 | 10 | 11 | 12 | 13 |
| 14 | 15 | 16 | 17 | 18 | 19 | 20 |
| 21 | 22 | 23 | 24 | 25 | 26 | 27 |
| 28 | 29 | 30 | 31 |
Tags
- ios
- Combine
- SeSAC
- Tuist Swift
- Firebase
- swift
- Subject
- SwiftUI
- swift db
- Firebase Analytics
- xcode
- combinecocoa
- JSON
- Tuist
- KeyPath
- observable
- realm
- arc
- RxSwift
- swift database
- 카카오뱅크 ios
- uitableviewdiffabledatasource
- Swift Tuist
- swift 5.9
- ios database
- swift 6
- ribs
- 네트워크 통신
- GCD
- Subscribe
Archives
- Today
- Total
천원의 개발
swift outerLoop 사용법 본문
기존 for문은 break문을 통해 벗어날 수 있는데 중첩 for문은 어떤식으로 벗어날 수 있을까?
outerLoop: for i in 1...10 {
for j in 1...10 {
let product = i * j
print ("\(i) * \(j) is \(product)")
//만약 product가 50이면 루프에서 빠져나온다.
if product == 50 {
print("구구단 그만!")
break outerLoop
}
}
}
위 처럼 outerLoop를 활용하면 된다.
'Swift 코딩테스트 준비' 카테고리의 다른 글
| swift n진법 변경하기! (0) | 2022.06.12 |
|---|---|
| swift Dictionary 정렬하기 (0) | 2022.05.30 |
| stride(form: to: by:) (0) | 2022.05.18 |
| uppercased, lowercased (0) | 2022.05.18 |
| Swift forEach 정리 (0) | 2022.05.15 |