SplitScript reference / Language / loop

loop

keyword

loop { ... }

Repeats a block until it breaks.

Without a reachable break, loop has type Never and cannot fall through. break value exits the nearest loop expression and supplies its result; all such values are inferred bidirectionally as one type. A bare break supplies None. Value-carrying breaks are deliberately unavailable in while and runtime for loops. continue starts the next iteration. In an async context, await and retry preserve the loop and its live values across ticks.

Examples

Repeat without falling through

loop {
    await nextTick()
}

Break with a value

let moduleName = loop {
    if useVulkan {
        break "EngineWin64sv.dll"
    }
    break "EngineWin64s.dll"
}