Solidity REPL
Syntax & control flow

Named return values

Assign named return variables without writing an explicit return tuple.

Solidity 0.8.36REPL mode

Why use this example

Use this pattern to isolate Solidity branching, looping, assignment, and function-call syntax before combining it with contract state. The entry isolates named return values so its input, result, and state changes stay easy to compare.

Solidity to run

function calculate(uint256 left, uint256 right) public pure returns (uint256 sum, uint256 product) {
  sum = left + right;
  product = left * right;
}

calculate(6, 7)

Official Solidity reference

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

Return variables

What to expect

The named return variables are assigned in the function body and return the sum 13 and product 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 writing Solidity Prototype Solidity behavior