1️⃣ if
if someCondition {
print("Do something")
} else if someCondition {
print("Do something")
} else {
print("Do something")
}
2️⃣ switch
enum Weather {
case sun, rain, wind, snow, unknown
}
let forecast = Weather.sun
switch forecast {
case .sun:
print("It should be a nice day.")
case .rain:
print("Pack an umbrella.")
case .wind:
print("Wear something warm")
case .snow:
print("School is cancelled.")
case .unknown:
print("Our forecast generator is broken!")
}
3️⃣ ternary conditional operator ( 삼항조건연산자 )
let hour = 23
print(hour < 12 ? "It's before noon" : "It's after noon")
// Some condition ? True : False
'iOS > SwiftUI' 카테고리의 다른 글
[SwiftUI] Setting App Icon (0) | 2023.08.05 |
---|---|
[Day 6] 반복문 : Loop (for, while), break & continue (0) | 2023.08.05 |
[Day 4] Type annotations (0) | 2023.08.03 |
[Day 3] 배열(Array) , 딕셔너리(Dictionary) , 집합(Set), Enum (0) | 2023.08.02 |
[Day 2] 부울, 문자열 결합 (0) | 2023.08.01 |