Skip to main content

repeat

The repeat loop is used to execute a block of code a fixed number of times.

repeat 5 {
Transmission { "Hello, world!" }
}
// Outputs "Hello, world!" 5 times

Returning Values

When repeat is used in an expression, the break statement determines the resulting value of the expression. If the loop exists without a break, the resulting value will be undefined.

let x = 3
let a = repeat {
if x < 10 {
break 5
}
}
// a will be either `5`