liveBook · Manning

Out position

An out position is a type-parameter usage position in which values of the parameterized type are produced or returned rather than consumed.

How 2 Manning books explain it

Kotlin in Action, 2E

An out position is a type-parameter usage position in which values of the parameterized type are produced rather than consumed.

How it is used
Constrains generic APIs to producer-only use so subtype relationships remain safe.
How deep it goes
Explains return and parameter positions, declaration-site restrictions, covariance, and collection examples without descending into runtime implementation.
Examples
Uses Producer, Herd<Cat>, Herd<Animal>, List, and MutableList to contrast producing values with consuming them.
What you can do after
Apply it via Kotlin's out modifier to design producer-like generic types with safe covariance.

Read how Kotlin in Action, 2E explains out position →

Fabulous Adventures in Data Structures and Algorithms

An output position is a type-parameter occurrence where values of the parameterized type are produced or returned rather than consumed.

How it is used
Uses output positions to determine when generic interfaces can safely support covariance.
How deep it goes
Explains returned values, getters, consumed parameters, and an extension-method workaround, then connects them to type safety.
Examples
Uses IEnumerable<T>, IE<T>, an immutable stack, and Animal, Giraffe, and Tiger assignments.
What you can do after
Apply it via C# generic interfaces to recognize safe covariance and relocate consuming operations into extension methods.

Read how Fabulous Adventures in Data Structures and Algorithms explains out position →

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.