Ternary and boolean logic
Combine a conditional expression with AND, OR, and negation.
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 ternary and boolean logic so its input, result, and state changes stay easy to compare.
Solidity to run
bool active = true
uint256 reward = active ? 42 : 0
bool eligible = active && reward > 10
bool blocked = !eligible || reward == 0
reward
eligible
blockedOfficial Solidity reference
Compare this focused investigation with the complete language definition in the Solidity documentation.
OperatorsWhat to expect
The ternary chooses reward 42, the eligibility expression is true, and the blocked expression is false.
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