Solidity REPL
Types & storage

Internal function values

Pass a Solidity function as a typed value to another function.

Solidity 0.8.36REPL mode

Why use this example

Use this pattern to explore how Solidity represents typed values and how state-changing expressions affect storage. The entry isolates internal function values so its input, result, and state changes stay easy to compare.

Solidity to run

contract FunctionValues {
  function double(uint256 value) internal pure returns (uint256) {
    return value * 2;
  }
  function transform(uint256 value, function(uint256) pure returns (uint256) operation) internal pure returns (uint256) {
    return operation(value);
  }
  function run() external pure returns (uint256) {
    return transform(21, double);
  }
}

FunctionValues functions = new FunctionValues()
functions.run()

Official Solidity reference

Compare this focused investigation with the complete language definition in the Solidity documentation.

Function types

What to expect

The internal double function is passed as a typed value and apply returns 42.

Continue the investigation

Change a value, add another expression, or open Inspect after the run. Accepted entries remain available to the next entry, and the clean replay keeps the complete result reproducible.

Read about state and storage Reproducible investigation