menu
172 tokens

Control Flow

Control Flow

Control Flow

  • if let and while let bind a refutable pattern for the successful branch or iteration
  • loop is the explicit infinite-loop form and produces values through break 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";