Sazzad Hissain Khan Sazzad Hissain Khan - 1 month ago 4x
Swift Question

do while loop in Swift

I know that while and for loop is useful in most of the cases. But still is some situation do-while loop is more useful. My question is what is the equivalent syntax for do while in Swift?


Here’s the general form of a repeat-while loop for Swift

repeat {
} while condition

For example,

repeat {
    //take input from io standard into n
} while n <= 10

This loop will run until you provide n > 10