나의 발자취
Switch Statement: Where clause 본문
var randomNumber = Int.random(in: 0...10)
switch randomNumber {
case let x where x % 2 == 0:
print("\(randomNumber) is even")
case let x where x % 2 == 1:
print("\(randomNumber) is odd")
default:
print("Invalid")
}
case에서 임시변수 x를 선언 후 where 문으로 조건 설정 가능(람다같이)
'앱 개발 > iOS' 카테고리의 다른 글
View: Vstack, Hstack, Zstack (0) | 2023.06.20 |
---|---|
SwiftUI View란? View Modifiers (0) | 2023.06.20 |
XCode 파일 구조(Project navigator File lists) 설명 (1) | 2023.06.14 |
Bundle Identifier? Organization Identifier? (0) | 2023.06.13 |
iOS developing - Wireframing, compound assignment operators (1) | 2023.06.13 |
Comments