Rullst AcademyRullst Academy/Lesson
Rust: from idea to program · Lesson 03 / 08

The decision at the boundary

A door should open with ten points or more. Nine, ten and eleven are neighbors, but reveal whether we wrote the right rule.

Learning paths8 min

Let's discover together

  1. 1

    if takes one path when a condition is true. else describes the other path. The condition must be bool, not just “any nonzero number.”

  2. 2

    points >= 10 means “points is greater than or equal to 10.” points > 10 excludes 10. One symbol changes the boundary.

  3. 3

    In Rust, if can also produce a value: let open = if points >= 10 { true } else { false };. Here the comparison already produces bool and can be used directly.

  4. 4

    Test below, exactly at and above the boundary. These small cases reveal mistakes a single distant value could hide.

✦
YOUR MISSION

Test both sides of the boundary and the boundary itself before approving the condition.

Now it's your turn

Discovery workshop

The ten-point door

Rule: if points >= 10 { open } else { keep closed }. Choose each test result.
Build your answers and check when you are ready.
A moment to understand

Which comparison means “ten or more”?

I need a hint

“Or more” includes ten itself.

Loading your journey…

Take it with you

If the rule becomes “fewer than five attempts,” which three numbers would you test? Remember that < excludes the boundary.

Show me the Rust behind it

This part is optional. You don't need to memorize the code to continue.

fn main() {
    for points in [9, 10, 11] {
        let open = points >= 10;
        println!("{points}: {open}");
    }
}
At your own pace

My files and GitHub

Every lesson can become your own record: code, notes or a practice plan. Saving a file to GitHub is optional and does not change your XP.

Student guide

The editor and downloads open when this lesson is available to your account. Check access below or return to the track map.

Checking your access to this lesson…

Rullstpetbot

AI can make mistakes. Check the lesson material.