liveBook · Manning

Multiple return values

Multiple return values are function results in which a single invocation provides more than one distinct value.

How 2 Manning books explain it

Go in Practice, Second Edition

How it is used
Pairs distinct Go function results, especially a useful value with a trailing error for caller-side handling.
How deep it goes
Shows return signatures, assignments, named returns, and error checks, without exploring runtime internals.
Examples
Uses a two-string function and a string concatenator with successful and missing-input paths.
What you can do after
Build it from scratch: define Go functions with multiple results and check errors before relying on associated values.

Read how Go in Practice, Second Edition explains multiple return values →

Python How-To

Multiple return values are values expressed by a function return statement and represented at runtime as one returned object, commonly a tuple.

How it is used
Simplifies downstream processing when one function produces several closely related results.
How deep it goes
Explains tuple packing and unpacking, while stopping short of broader return-object design.
Examples
Uses a statistics function returning a mean and standard deviation, then unpacks its tuple result.
What you can do after
Apply tuple packing and unpacking to return and consume related results from Python functions.

Read how Python How-To explains multiple return values →

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.