You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
IsaacShelton edited this page Mar 21, 2022
·
1 revision
Until Break Statement
Until break statements are used to conditionally execute a block of code until a break is encountered
until break {
// ...
}
Execution Condition
The code inside the block will be executed or be re-executed until a break is encountered
Usage example
import basics
func main {
value int = 0
until break {
value = scanInt("Enter a value that isn't zero: ")
if value != 0, break
}
print("You entered " + value)
}
Break and Continue
Both break and continue apply to until break statements
Loop Labels
Loop labels can be used for until break loops by specifying a name for the loop label after until break
name String = ""
until break waiting_for_valid_name {
name = scan("Enter your name: ")
if isInvalid(name) {
print("Please enter a valid name!")
} else {
break waiting_for_valid_name
}
}