-
-
Notifications
You must be signed in to change notification settings - Fork 9
Until Statement
IsaacShelton edited this page Mar 21, 2022
·
1 revision
Until statements are used to conditionally execute a block of code until a condition is true
until condition {
// ...
}
until(condition){
// ...
}
until condition, // ...
until condition // ...
until(condition) // ...
until(condition), // ...
If the condition is false
, then the code inside the block will be executed or be re-executed
until
is the negated version of the while
statement
import basics
func main {
value int = scanInt("Please don't enter 10: ")
until value == 10 {
value = scanInt("Please don't enter 10: ")
}
print("You entered 10, goodbye")
}
Both break
and continue
apply to until
statements
Loop labels can be used for until
loops by specifying a name for the loop label followed by :
before the condition
until ready : downloadedFile.isFinished() {
if downloadedFile.failed(), break ready
waitForSomeTime()
}
A version of until
exists called until break
x int = 0
until break {
if ++x == 10, break
}
See until break
for more information