liveBook · Manning

Yield

A language construct that yields control from a computation, optionally passing a value to another context, and may allow the suspended computation to continue later.

How 10 Manning books explain it

Get Programming with JavaScript Next: New features of ECMAScript 2015, 2016, and beyond

A JavaScript keyword used inside generator functions to pause execution and produce or receive a value.

How it is used
Uses `yield` to pause generator functions, send values outward, and receive values when execution resumes.
How deep it goes
Works through generator lifecycle and `next()` results, including the unused first argument, while leaving broader generator applications for later.
Examples
Uses successive yields, infinite numbers, Fibonacci numbers, adaptive simulation objects, and a timed CPU turn.
What you can do after
Build it from scratch: create generators that yield requested values and accept feedback through `next()`.

Read how Get Programming with JavaScript Next: New features of ECMAScript 2015, 2016, and beyond explains yield →

Secrets of the JavaScript Ninja, Second Edition

An expression in a JavaScript generator that yields a value and evaluates to a value supplied when execution resumes.

How it is used
Uses yield to produce generator values on request while suspending execution between requests.
How deep it goes
Explains yield through iterator results and resumed expressions, then shows delegation and injected exceptions; stops short of runtime internals.
Examples
Uses weapon sequences, generator-to-generator delegation, and a two-way exchange through next().
What you can do after
Build it from scratch by yielding a sequence and receiving a value when the generator resumes.

Read how Secrets of the JavaScript Ninja, Second Edition explains yield →

The Well-Grounded Rubyist, Fourth Edition

yield is a Ruby keyword that transfers execution to the block associated with the currently running method and then resumes the method afterward.

How it is used
Enables iterator methods to run caller-supplied blocks and resume their own work afterward.
How deep it goes
Works through repeated yielding, values passed to blocks, block results, and method returns using custom iterator implementations.
Examples
Uses `my_loop`, `Integer#my_times`, `Array#my_map`, and an indented-list generator to show successive uses of `yield`.
What you can do after
Build it from scratch: write iterators that pass values to blocks, collect their results, and choose a method return value.

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

Python Workout: 50 ten-minute exercises

yield is a Python statement that produces a value from a generator function while suspending its execution until the next value is requested.

How it is used
Deploys yield to write lazy generators that supply iterable values incrementally.
How deep it goes
Explains suspension, resumption, automatic termination, and retained locals, while contrasting generators with explicit iterator classes.
Examples
Demonstrates numbered values, filtered file lines, retained timing state, and chaining multiple iterables.
What you can do after
Builds generators that stream values, preserve state, filter input, and combine iterables without implementing iterator methods manually.

Read how Python Workout: 50 ten-minute exercises explains yield →

C# Concurrency: Asynchronous and multithreaded programming

Yield return is a C# language feature that produces an iterator element and suspends execution until the iterator advances again.

How it is used
Uses iterator methods to generate sequences on demand and establish compiler-transformation fundamentals for async/await.
How deep it goes
Explains generated enumerable and enumerator classes, resumable chunks, state tracking, MoveNext, and asynchronous iterator extensions.
Examples
Demonstrates list-based and yield-based sequences producing 1 and 2, then extends the pattern to asynchronous data and work queues.
What you can do after
Build iterator methods and asynchronous sequences, consume them with foreach or await foreach, and understand their generated control flow.

Read how C# Concurrency: Asynchronous and multithreaded programming explains yield →

Python Workout, Second Edition

yield is a Python statement or expression that produces a value from a generator function while suspending its execution for later resumption.

How it is used
Builds lazy iterators that return one value at a time when requested.
How deep it goes
Explains suspension, resumption, automatic termination, and retained local state across iterations.
Examples
Uses a three-value foo generator, for-loop consumption, iterable chaining, and elapsed-time reporting.
What you can do after
Build it from scratch using generator functions that yield sequences while preserving state between requests.

Read how Python Workout, Second Edition explains yield →

.NET in Action, Second Edition

yield return is C# iterator syntax that produces an element and suspends execution until the next element is requested.

How it is used
Generates xUnit MemberData cases and forwards processed elements through synchronous or asynchronous enumerations.
How deep it goes
Explains one-at-a-time enumeration, collection avoidance, object-reuse pitfalls, and async-stream composition without detailing compiler-generated state machines.
Examples
Demonstrates independent Sudoku boards for theory tests and enriched Comic objects returned from asynchronous searches.
What you can do after
Build it from scratch to generate test cases or stream transformed asynchronous results one element at a time.

Read how .NET in Action, Second Edition explains yield →

Python How-To

The yield keyword pauses a generator function, provides a value to its caller, and allows execution to resume later from the pause point.

How it is used
Deploys yield to create generators that render values lazily during iteration.
How deep it goes
Explains pausing, resumption, state retention, exhaustion, next, and StopIteration, while deferring coroutine details.
Examples
Uses perfect-square generators, manual next calls, generator expressions, and sums to demonstrate lazy production and consumption.
What you can do after
Build it from scratch by writing generator functions that yield values incrementally and resume correctly across iteration.

Read how Python How-To explains yield →

Idiomatic Rust

A yield statement suspends a coroutine and optionally supplies a value to its caller.

How it is used
Passes values from a suspended coroutine to its caller, including when building iterators over data streams.
How deep it goes
Traces yielding through resume calls and coroutine states, with a basic example; defers more complex scenarios.
Examples
Demonstrates yielding π before returning a string, and yielding numbered file lines for an iterator.
What you can do after
Build a coroutine closure that yields values on resume and returns a completion value.

Read how Idiomatic Rust explains yield →

Fabulous Adventures in Data Structures and Algorithms

yield return is C# iterator-block syntax that produces sequence elements on demand during enumeration.

How it is used
Generates permutation sequences incrementally during enumeration.
How deep it goes
Explains deferred execution, recursive implementation, desugared calls, and enumeration complexity.
Examples
Demonstrates recursive change-ringing permutations and a yield-based InsertAt helper.
What you can do after
Apply it via C# iterator methods to produce sequence elements on demand and analyze enumeration costs.

Read how Fabulous Adventures in Data Structures and Algorithms explains yield →

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.