Menu
Coddy logo textTech

Boolean Data Type

Part of the Fundamentals section of Coddy's Ruby journey — lesson 6 of 88.

The boolean data type can only hold two possible values: true and false. These values represent the concepts of true and false, which are fundamental for controlling program flow and making comparisons. Notice that both values are written in lowercase without quotes.

Creating a boolean variable follows the same pattern you've learned:

is_complete = true
has_error = false

Boolean values become incredibly useful when your program needs to make decisions, check conditions, or store the results of comparisons. They form the foundation for controlling what your code does in different situations.

challenge icon

Challenge

Easy

Create three boolean variables to represent different system states. First, create a variable called is_online and assign it the value true. Then create a variable called has_permission and assign it the value false. Finally, create a variable called system_ready and assign it the value true. Display all three variables using the puts command.

Cheat sheet

The boolean data type holds two possible values: true and false. Both values are written in lowercase without quotes.

Creating boolean variables:

is_complete = true
has_error = false

Boolean values are used for making decisions, checking conditions, and storing comparison results.

Try it yourself

# TODO: Write your code here
# Create the three boolean variables and display them using puts
quiz iconTest yourself

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

All lessons in Fundamentals