Files
carbon-lang/docs/design/control_flow
199c7e365c var ordering (#618)
Propose the decision from #542, noting implementation from #563

Also integrates some of #339 into `variables.md` because that's actually how this started, looking for a proposal reference for #542 

Co-authored-by: Richard Smith <richard@metafoo.co.uk>
Co-authored-by: josh11b <josh11b@users.noreply.github.com>
2021-07-09 11:49:32 -07:00
..
2021-07-09 11:49:32 -07:00

Control flow

Overview

Blocks of statements are generally executed linearly. However, statements are the primary place where this flow of execution can be controlled.

Carbon's flow control statements are:

  • if and else provides conditional execution of statements.
  • Loops:
    • while executes the loop body for as long as the loop expression returns True.
    • for iterates over an object, such as elements in an array.
    • break exits loops.
    • continue goes to the next iteration of a loop.
  • return ends the flow of execution within a function, returning it to the caller.