Menu
Coddy logo textTech

Comparisons

Part of the Fundamentals section of Coddy's Solidity journey. Lesson 16 of 53.

A comparison produces a boolean. Use == for equality, != for inequality, and <, >, <= or >= for ordering. Equality uses two equals signs because a single = assigns a value.

The statements in this excerpt run inside the provided main function.

uint256 points = 16;
console.log(points >= 12);
console.log(points == 12);

Sixteen meets the minimum of twelve but is not exactly twelve. The equals sign in >= includes the boundary. Checking that boundary is useful when writing and testing a condition.

A comparison produces a bool, and >= includes equality at the boundary.

challenge icon

Challenge

Easy

Print whether score is at least minimum, then whether it is exactly the minimum.

The tests pass arguments to main in this order: uint256 score, uint256 minimum. Each test starts with fresh contract state.

Use console.log for the requested output. Print only the requested values, one per line, with no extra labels unless the task specifies them.

Try it yourself

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.26;
import "forge-std/console.sol";
contract Main {
    function main(uint256 score, uint256 minimum) external view {
        // Write your solution here.
    }
}
quiz iconTest yourself

This lesson includes a short quiz. Start the lesson to answer it and track your progress.

All lessons in Fundamentals

Practice on your own: Solidity playground