모바일 앱개발/Swift
플로우 컨트롤 복습하기 (21.09.5주)
GeekCode
2021. 10. 1. 23:56
반응형
1. 조건문
if
if Boolean value {
true statements
} else {
false statements
}
switch
- value 에는 숫자형, 문자형, 튜플도 가능
switch value {
case condition :
statements
case condition :
statements
case condition :
statements
}
2. 반복문 (For Loop, While Loop)
For - in
for-in은 statements의 사항을 ragne 만큼 반복 함.
for item in items {
/* 실행 구문 */
}
For - where
for i in closedRange where i % 2 == 0
While
while, reapet-while 두 구문 모두 condition이 참인 동안 계속해서 반복함.
while condition {
statements
}
Repeat- While
repeat {
statements
} while condition
반응형