Files
carbon-lang/docs/design/control_flow
Richard SmithandGeoff Romer df3cf92943 Adopt ref in Core.Iterate.Next (#7381)
Change the `cursor` parameter in `Core.Iterate.Next` to be a `ref`
parameter
instead of a pointer parameter.

Assisted-by: Gemini via Antigravity

---------

Co-authored-by: Geoff Romer <gromer@google.com>
2026-10-07 23:14:42 +00: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.