SplitScript reference / Language / break

break

keyword

break | break value

Exits the nearest enclosing loop.

break is an ordinary Never-typed expression which exits the innermost while, runtime for, or loop. Inside a loop expression, break value also supplies the expression's result; a bare break produces None. Value-carrying breaks are rejected in while and for so they can never accidentally skip an inner statement loop to target an outer value loop. Because it never yields locally, break can appear in any expression position whose evaluation may exit that loop, including a fallback else.

Examples

Exit a conditional loop

while !found {
    if cannotContinue { break }
}

Produce a loop value

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