0Pricing
Dart Academy · Lesson

Booleans and Comparison Operators

Produce true and false from comparisons.

Booleans and Comparison Operators is a free Dart Academy lesson on CoddyKit — lesson 1 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Dart Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.

Yes or No, True or False

Every decision your program makes starts with a yes-or-no answer. In Dart that answer is a bool, which holds only true or false. 🤔

Declaring a bool

You store a yes-or-no value in a variable typed as bool. It can hold the literal true or the literal false, and nothing else.

bool isReady = true;
bool isDone = false;

Comparisons Make Booleans

You rarely type true by hand. Instead a comparison produces a bool for you, answering questions about your values automatically.

bool big = 10 > 3; // true

Equal and Not Equal

Use == to ask if two values are equal, and != to ask if they differ. Both give you back a clean true or false.

print(5 == 5);  // true
print(5 != 2);  // true

Greater and Less Than

The > and < operators compare order. They answer whether the left value is larger or smaller than the right one.

print(8 > 3);  // true
print(2 < 1);  // false

Or Equal To

Add an equals sign to include the boundary. >= and <= are true when the values are equal as well as when one is bigger.

print(5 >= 5); // true
print(4 <= 9); // true

Comparing Text

You can compare strings too. With ==, two strings are equal only when their characters match exactly, including letter case.

print("cat" == "cat"); // true
print("Cat" == "cat"); // false

Watch the Double Equals

A single = assigns a value, while == compares two values. Mixing them up is a classic beginner slip, so read twice.

var x = 5;        // assign
print(x == 5);    // compare

Store the Result

A comparison is just an expression, so you can save its bool result in a variable and reuse it wherever you need that answer.

int age = 20;
bool adult = age >= 18; // true

Flip It With Not

Put ! in front of a bool to flip it. True becomes false and false becomes true, handy for asking the opposite question.

bool open = false;
print(!open); // true

Booleans Drive Decisions

These true and false values are the fuel for branching. Soon an if statement will read a bool and choose which code to run. 🚦

Quick Check

Which operator asks whether two values are equal?

Recap

You learned that a bool holds true or false, and that ==, !=, >, <, >=, <=, and ! build those values for decisions. 🎉

Frequently asked questions

Is the “Booleans and Comparison Operators” lesson free?

Yes — the full text of “Booleans and Comparison Operators” is free to read here on the web, and the Dart Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Dart Academy course, upgrade to CoddyKit PRO.

What will I learn in “Booleans and Comparison Operators”?

Produce true and false from comparisons. You practise Dart Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.

Do I need any experience to start Dart Academy?

No prior experience is required. Dart Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 1 of 4, so you can start here or from the beginning and move at your own pace.

How long does the “Booleans and Comparison Operators” lesson take?

Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.

Can I write and run code in this Dart Academy lesson?

Yes. Every Dart Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.

All lessons in this course

  1. Booleans and Comparison Operators
  2. if, else if, and else
  3. Logical Operators and Short-Circuiting
  4. The Ternary and switch Expression
← Back to Dart Academy