Ruby Language Comparison Operators


Example

OperatorDescription
==true if the two values are equal.
!=true if the two values are not equal.
<true if the value of the operand on the left is less than the value on the right.
>true if the value of the operand on the left is greater than the value on the right.
>=true if the value of the operand on the left is greater than or equal to the value on the right.
<=true if the value of the operand on the left is less than or equal to the value on the right.
<=>0 if the value of the operand on the left is equal to the value on the right,
1 if the value of the operand on the left is greater than the value on the right,
-1 if the value of the operand on the left is less than the value on the right.