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.



We’ve got two variables in the editor: is_true and is_false. Replace the __ with == or != to make is_true evaluate to true and is_false evaluate to false.

Take this course for free

Mini Info Outline Icon
By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.

Or sign up using:

Already have an account?