본문 바로가기
앱/iOS(Swift)

[Swift] while, repeat while 차이

by 리드맥 2022. 1. 23.
  • 조건문이 맞으면 실행
var a = 3
var b = 6

while a < b {
  print(a)
  a = a + 1
}

3
4
5

  • 조건문이 틀려도 무조건 한번은 실행
repeat{
    print(a)
    a = a + 1
} while a > b

3

' > iOS(Swift)' 카테고리의 다른 글

[Swift] for in, forEach 차이  (0) 2022.01.23
[Swift] DeadLock  (0) 2022.01.23
[Swift] 코드로 버튼 넣어보기  (0) 2022.01.23
[Swift] DateFormat 변환법  (0) 2022.01.23
[Swift] Codable, CodingKey  (0) 2022.01.23

댓글