liveBook · Manning

Block

A code block is a grouped region of code treated as a unit, with boundaries and scope or execution behavior determined by its language or context.

How 5 Manning books explain it

The Well-Grounded Rubyist, Fourth Edition

A block is a fragment of Ruby code supplied with a method call that the method can execute.

How it is used
Uses blocks to supply executable behavior to method calls, especially iterators and scoped operations.
How deep it goes
Explains yielding, parameters, return values, scope, precedence, and proc conversion through small implementations and contrasts.
Examples
Builds homemade loop, times, and map methods and contrasts block-based file access with an explicit read loop.
What you can do after
Build it from scratch in simple iterators, then apply it to collection processing and scoped file access.

Read how The Well-Grounded Rubyist, Fourth Edition explains block →

Get Programming: Learn to code with Python

How it is used
Uses indented code blocks to control which statements run when an if condition is true.
How deep it goes
Explains indentation, conditional execution, and nested blocks, but does not treat blocks beyond conditional statements.
Examples
Uses positive, negative, and zero checks, plus nested decisions about hunger and chocolate prices.
What you can do after
Apply Python if statements to write, test, and debug programs that make decisions.

Read how Get Programming: Learn to code with Python explains block →

The Quick Python Book, Fourth Edition

A code block is a sequence of one or more statements grouped as a syntactic unit and executed under a common control structure.

How it is used
Structures loop bodies, conditional clauses, and other compound statements through indentation.
How deep it goes
Defines block membership, nesting, single-line cases, and indentation errors, but does not discuss interpreter internals.
Examples
Uses factorial calculation, conditional assignment, nested interactive blocks, and examples of unexpected or mismatched indentation.
What you can do after
Apply indentation to write nested control-flow bodies and diagnose common indentation errors.

Read how The Quick Python Book, Fourth Edition explains block →

Learn Rust in a Month of Lunches

A code block is a delimited sequence of Rust statements and expressions that forms a lexical scope and produces a value.

How it is used
Introduces lexical scope, variable lifetimes, and expression values while teaching Rust's first declarations and functions.
How deep it goes
Defines scope and return behavior through small examples, then stops short of deeper ownership or lifetime analysis.
Examples
Uses nested numeric blocks, out-of-scope variables, arithmetic block values, and functions returning integers.
What you can do after
Apply code blocks to limit variable scope and compute values, using compiler feedback to correct semicolon and lifetime mistakes.

Read how Learn Rust in a Month of Lunches explains block →

Modern C, Third Edition

A block is a grammatical structure that groups declarations and statements within a delimited program region.

How it is used
Organizes declarations and statements into nested grammatical regions whose boundaries determine identifier visibility.
How deep it goes
Defines block grammar, distinguishes primary and secondary blocks, and traces four nested scope levels without descending into implementation mechanics.
Examples
Uses main, its parameter list and body, and a for loop with a nested loop body.
What you can do after
Evaluate/understand identifier visibility by locating declaration points and enclosing blocks.

Read how Modern C, Third Edition explains block →

Related concepts

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.