Sazzad Hissain Khan Sazzad Hissain Khan - 4 months ago 15
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