Closed Suyeon9911 closed 1 year ago
for-in 구문
while 구문
var names: [String] = ["1", "2", "3" "4"]
while names.isEmpty == false { print("good bye (names.removeFirst())") }
var numbers: [Int] = [3, 2342, 6, 3252]
numbersLoop: for num in numbers {
if num > 5 || num < 1 {
continue numbersLoop
}
var count: Int = 0
printLoop: while true {
print(num)
count += 1
if count == num {
break printLoop
}
}
removeLoop: while true {
if numbers.first != num {
break numbersLoop
}
numbers.removeFirst()
}
}
조건문, 반복문
조건문
1. if 구문은 조건의 값이 꼭 Bool 타입이어야합니다
where를 사용하여 case의 조건을 확장할 수 있다.
만약, 이후에 열거형에 case가 추가될 경우 ? 컴파일오류 발생 스위프트 5.0 버전에서 추가된 unknown이라는 속성으로 대처