Solidity REPL
Contracts & calls

Inheritance and override

Check virtual functions, super calls, and overrides.

Solidity 0.8.36REPL mode

Why use this example

Use this pattern to test contract composition, external calls, events, and return values inside one reproducible run. The entry isolates inheritance and override so its input, result, and state changes stay easy to compare.

Solidity to run

contract Base {
  function answer() public pure virtual returns (uint256) { return 40; }
}
contract Child is Base {
  function answer() public pure override returns (uint256) { return super.answer() + 2; }
}
Child child = new Child()
child.answer()

What to expect

The child override calls its base implementation through super and returns the final value 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 calls and logs Reproducible investigation