menu
172 tokens
Control Flow
Control Flow
Control Flow
if letandwhile letbind a refutable pattern for the successful branch or iterationloopis the explicit infinite-loop form and produces values throughbreak value- labeled loops accept
break label: value
Loops
For convenience and clarity, Destack supports loop as the explicit infinite loop form, and like other expressions, loops can produce a value through break.
1declare function readInput(): string;2declare function process(input: string): void;3 4const line = loop {5 const input = readInput();6 if (input == "quit") {7 break "done";8 }9 process(input);10};11 12let status = outer: loop {13 break outer: "done";14};15status satisfies "done";