liveBook · Manning

Local function

A local function is a function defined within another function or definition and scoped to its enclosing body or local scope.

How 2 Manning books explain it

Kotlin in Action, 2E

A local function is a function declared within another function or local scope rather than at the top level or as a class member.

How it is used
Structures function-specific helper logic while avoiding duplicated validation and unnecessary class methods.
How deep it goes
Explains nesting, scope, duplication removal, and captured parameters, then stops at an extension-function alternative.
Examples
Uses saveUser validation for empty name and address fields, first passing User explicitly and then capturing it.
What you can do after
Apply it in Kotlin to organize function-local validation and remove small repetitions without expanding a class API.

Read how Kotlin in Action, 2E explains local function →

React Quickly, Second Edition

A local function is a function defined within another function and accessible within that enclosing function's lexical scope.

How it is used
Converts class methods that depend on component-local information into functional-component code.
How deep it goes
Compares pure and local functions with concrete calls and JSX, but does not develop deeper implementation internals.
Examples
Uses an Image component whose local getImageSource function builds a Picsum image URL from index.
What you can do after
Apply it via functional components to retain compact calls while accessing component-local values.

Read how React Quickly, Second Edition explains local function →

Also covered in

Related concepts

Questions about local function

What is local function?

A local function is a function defined within another function or definition and scoped to its enclosing body or local scope.

Which Manning books explain local function?

Kotlin in Action, 2E and React Quickly, Second Edition.

What is the difference between local function and class method?

A local function is a function defined within another function or definition and scoped to its enclosing body or local scope. A class method is a method associated with a class rather than a particular instance and invoked through a class or class-related object.

What is local function a kind of?

Local function is a kind of function. 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.

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.