← Back to Ruby Course | Chapter 2: Variables & Types | Lesson 4 of 7

Boolean Values

In this page:

  1. Boolean Values

Boolean Values

Ruby has true and false as the literal boolean values, both instances of their own classes (TrueClass and FalseClass). Comparison and logical operators produce these values directly. Ruby's boolean handling is simple, but its rules for what counts as "truthy" in a condition are broader than just true/false, covered in a later chapter.

Note: true and false are singleton objects in Ruby, each the sole instance of their own class.

Example: Boolean Values

markup
is_active = true
is_admin = false

puts is_active.class
puts is_active && is_admin
puts 10 > 5
🔒

Chapter Quiz — Complete all 7 topics to unlock

0/7 topics done

Complete these topics first:

Login to run this code

C/C++/Java/PHP execution requires a free account. Your code is saved — you'll land right back in the editor after logging in.