A Full List of Number Comparison Operators in Ruby : Comparison Operators « Language Basics « Ruby






A Full List of Number Comparison Operators in Ruby


Comparison     Meaning 
x > y          Greater than.
x < y          Less than.
x == y         Equal to.
x >= y         Greater than or equal to.
x <= y         Less than or equal to.
x <=> y        Comparison. 
c              Returns 0 if x and y are equal, 1 if x is higher, -1 if y is higher.
x != y         Not equal to.

 








Related examples in the same category

1.Comparison Operators and Expressions
2.Comparable module uses the <=> operator on the class that includes it.
3.Equality, Less Than, or Greater Than
4.The == and eql? return true or false