If and else branches
Follow a value through ordered conditional branches.
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 if and else branches so its input, result, and state changes stay easy to compare.
Solidity to run
function classify(uint256 value) public pure returns (uint256) {
if (value < 10) return 1;
else if (value < 100) return 2;
else return 3;
}
classify(7)
classify(42)
classify(420)Official Solidity reference
Compare this focused investigation with the complete language definition in the Solidity documentation.
Control structuresWhat to expect
The three calls take the first, second, and final branch and return 1, 2, and 3 respectively.
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