0
0
Rubyprogramming~15 mins

Boolean values (true, false, nil) in Ruby - Mini Project: Build & Apply

Choose your learning style9 modes available
Working with Boolean Values in Ruby
📖 Scenario: Imagine you are creating a simple system to track if a user is active, if they have admin rights, and if their profile is complete.
🎯 Goal: You will create variables with Boolean values true, false, and nil to represent user states, then print these values.
📋 What You'll Learn
Create three variables named is_active, is_admin, and profile_complete with exact Boolean or nil values.
Create a variable called unknown_status and set it to nil.
Use a puts statement to print all four variables in order.
💡 Why This Matters
🌍 Real World
Boolean values are used everywhere in programming to represent yes/no, on/off, or true/false conditions.
💼 Career
Understanding Boolean values is essential for writing conditions, controlling program flow, and handling optional data in software development.
Progress0 / 4 steps
1
Create Boolean variables for user states
Create three variables called is_active, is_admin, and profile_complete with the exact values true, false, and true respectively.
Ruby
Need a hint?

Use = true or = false to assign Boolean values.

2
Add a variable with nil value
Create a variable called unknown_status and set it to nil.
Ruby
Need a hint?

Use = nil to assign a nil value.

3
Print all variables
Use a single puts statement to print the variables is_active, is_admin, profile_complete, and unknown_status separated by spaces.
Ruby
Need a hint?

Use string interpolation with #{variable} inside double quotes to print variables separated by spaces.

4
Run the program to see the output
Run the program to display the values of is_active, is_admin, profile_complete, and unknown_status.
Ruby
Need a hint?

The output should show true false true followed by an empty space for nil.