Return type
A return type is the type, or absence of a type, associated with the result a function or method supplies to its caller.
Kotlin in Action, 2E
A return type is the statically determined type of the value returned by a function.
- How it is used
- Defines the result type of Kotlin functions and makes returned values visible at the declaration site.
- How deep it goes
- Explains declaration syntax, expression bodies, type inference, block-body restrictions, and public-API guidance.
- Examples
- Uses max, if, when, try, main, and command-line arguments to demonstrate returned values and functions without values.
- What you can do after
- Apply explicit and inferred return types when declaring Kotlin functions, including concise expression-body functions.
Essential TypeScript 5, Third Edition
A return type is the type of the value a function returns, whether inferred or specified by annotation.
- How it is used
- Clarifies what functions return, supports compiler checking, and makes optional or action-oriented results explicit.
- How deep it goes
- Explains inference, unions, annotations, void, and noImplicitReturns, but does not descend into function overload implementation.
- Examples
- Demonstrates calculateTax with numeric, number-or-undefined, and void console-writing results.
- What you can do after
- Evaluate function contracts, annotate results, interpret inferred unions, and diagnose incomplete return paths.
Read how Essential TypeScript 5, Third Edition explains return type →
Modern C, Third Edition
A return type is the type of value that a C function supplies to its caller, or void when it supplies no value.
- How it is used
- Uses return types to define function interfaces and guide how callers handle returned data.
- How deep it goes
- Explains prototypes, void conventions, and caller-side expression effects, but does not develop return-type rules beyond these examples.
- Examples
- Uses leapyear returning bool, swap_double returning void, and fbar returning double in an arithmetic expression.
- What you can do after
- Build it from scratch by declaring functions with appropriate parameter and return types and using their results correctly.
Learn Rust in a Month of Lunches
A return type is the type of value that a function produces when it completes.
- How it is used
- Explains how Rust functions communicate values to their callers.
- How deep it goes
- Connects arrow syntax, tail expressions, semicolons, unit type, early return, and compiler diagnostics.
- Examples
- Uses `give_number` returning `8` and `multiply` returning a calculated product.
- What you can do after
- Diagnose return-type mismatches and write functions that return values implicitly or early.
Read how Learn Rust in a Month of Lunches explains return type →
Also covered in
- Modern C
- Secrets of the JavaScript Ninja, Third EditionIn early access (MEAP)
- Rust in Action: Systems programming concepts and techniques
- Pro Angular 16
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.
- TypeScriptTypeScript is a statically typed superset of JavaScript that adds type-system features and is compiled to JavaScript.
- declarationA declaration is a language construct that introduces a program entity or name and specifies information about it, such as its type or properties.
- function declarationA function declaration is a source-language construct that introduces a function by specifying its name and parameter interface, and may also provide its implementation.
Related concepts
- function declarationpart of · A function declaration is a source-language construct that introduces a function by specifying its name and parameter interface, and may also provide its implementation.
- functionpart of · 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.
- TypeScript compilerproduced by · The TypeScript compiler analyzes and checks TypeScript source code and can emit JavaScript and declaration files.
- type hintsconfigured by · Type hints are source-code annotations that indicate the intended or expected types of program elements, with enforcement depending on the language and tools.
- union typeproduces · A union type is a type whose values can represent one of several specified alternative types or variants.
- exceptioncontrasts with · An exception is a runtime signal or value representing an abnormal condition that interrupts ordinary program flow and can be handled or propagated.
Questions about return type
What is return type?
A return type is the type, or absence of a type, associated with the result a function or method supplies to its caller.
Which Manning books explain return type?
Kotlin in Action, 2E, Essential TypeScript 5, Third Edition, Modern C, Third Edition and Learn Rust in a Month of Lunches.
What should I know before learning return type?
Manning books that teach return type usually introduce function, TypeScript, declaration and function declaration first.
What is the difference between return type and exception?
A return type is the type, or absence of a type, associated with the result a function or method supplies to its caller. An exception is a runtime signal or value representing an abnormal condition that interrupts ordinary program flow and can be handled or propagated.
What is return type part of?
Return type is part of function declaration. A function declaration is a source-language construct that introduces a function by specifying its name and parameter interface, and may also provide its implementation.
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.



