Toggle menu
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.
Revision as of 13:53, 21 August 2025 by Dylan (talk | contribs) (new: info, uses, evaluation)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

A code block is a section of source code that is isolated in some way from other parts of the program.

This often means that variables that are declared inside the code block cannot be referenced outside the code block. But code blocks can have other functions.

Uses of code blocks

edit edit source

In some languages such as Rust, code blocks have another use: to evaluate multiple statements down to a single value.

Usually, the last statement in the code block is taken to be the value of the code block itself. Code blocks do not always evaluate to a value though.