Click here to navigate the course.

Drag the edges to resize the window.

In Projects, you can keep track of your progress as you go throught the tasks. Check each item as you complete it!

Code Editor
Control Flow in Ruby

Equal or Not?

In Ruby, we assign values to variables using =, the assignment operator. But if we've already used = for assignment, how do we check to see if two things are equal? Well, we use ==, which is a comparator (also called a relational operator). == means "is equal to." When you type

x = 2 y = 2 if x == y print "x and y are equal!" end

you're saying: "if x equals y, print 'x and y are equal!'" You can also check to see if two values are not equal using the != comparator.

Report a Bug
If you see a bug or any other issue with this page, please report it here.