Tracks
/
Swift
Swift
/
Syllabus
/
repeat while
re

repeat while in Swift

1 exercise

About repeat while

Repeat-while loops are similar to while loops, however, these loops differ in that the Boolean expression appears, and is evaluated, after the body of the loop is executed. As a result, these loops always execute at least once.

repeat {
  print("This runs at least once")
} while false
print("Loop done")

// prints:
// This runs at least once
// Loop done
Edit via GitHub The link opens in a new window or tab

Learn repeat while