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.
Also covered in
What to know first
- functionA function is a callable unit of program code that performs a computation or operation, can accept inputs, and may produce a result or side effect.
Related concepts
- Goused by · Go is a statically typed, compiled, general-purpose programming language with garbage collection and 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 associations and supports retrieving values by key.
- functionproduced by · A function is a callable unit of program code that performs a computation or operation, can accept inputs, and may produce a result or side effect.
- tuplekind of · A tuple is a finite, ordered collection of values grouped as a single composite value, often with elements of different types.
- tuple unpackingused by · Tuple unpacking is assigning the elements of an iterable to multiple corresponding targets in a single operation.
Questions about multiple return values
What is multiple return values?
Multiple return values are function results in which a single invocation provides more than one distinct value.
Which Manning books explain multiple return values?
Go in Practice, Second Edition and Python How-To.
What should I know before learning multiple return values?
Manning books that teach multiple return values usually introduce function first.
What is multiple return values a kind of?
Multiple return values is a kind of tuple. A tuple is a finite, ordered collection of values grouped as a single composite value, often with elements of different types.
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.

