0
0
Rubyprogramming~5 mins

Comparison operators in Ruby - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What does the == operator do in Ruby?
The == operator checks if two values are equal. It returns true if they are the same, otherwise false.
Click to reveal answer
intermediate
What is the difference between == and === in Ruby?
== checks if two objects are equal in value. === is used mainly in case statements to test if an object matches a condition or belongs to a class.
Click to reveal answer
beginner
What does the < operator do?
The < operator checks if the value on the left is less than the value on the right. It returns true if yes, otherwise false.
Click to reveal answer
beginner
How does the != operator work?
The != operator checks if two values are not equal. It returns true if they are different, otherwise false.
Click to reveal answer
beginner
What will 5 >= 3 return in Ruby?
It will return true because 5 is greater than or equal to 3.
Click to reveal answer
Which operator checks if two values are exactly equal in Ruby?
A!=
B=
C==
D<
What does the != operator do?
AChecks if two values are not equal
BChecks if two values are equal
CAssigns a value
DChecks if left is less than right
Which operator is used in Ruby case statements to test matching?
A==
B!=
C<=
D===
What will 4 < 2 return?
Atrue
Bfalse
Cnil
Derror
Which operator checks if left value is greater than or equal to right value?
A>=
B!=
C==
D<=
Explain how to compare two numbers to check if one is less than the other in Ruby.
Think about the symbol that means 'less than'.
You got /3 concepts.
    Describe the difference between == and === operators in Ruby.
    One is for simple equality, the other is for pattern matching.
    You got /3 concepts.