Multiple return values
Multiple return values are function results in which a single invocation provides more than one distinct value.
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.
Related concepts
- Goused by · Go is a statically typed, compiled, garbage-collected programming language with built-in support for concurrency.
- os.ReadFileproduced by · os.ReadFile is a Go standard-library function that reads an entire named file and returns its contents as a byte slice and an error.
- Mapproduced by · A map is an associative data structure that stores key-value pairs and supports retrieving values by key.
- tuple unpackingused by · Tuple unpacking is assigning the elements of an iterable to multiple corresponding targets in a single operation.
- functionproduced by · A function is a callable program unit that performs an operation, may accept inputs, and can produce a result or side effect.
- tuplekind of · A tuple is a finite, ordered collection of elements treated as a single composite value or record.
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.

