Comparison Operators Flashcards
==
Checks if the value of two operands are equal or not, if yes then condition becomes true ex. a is 10 b is 20 (a==b) is false
!=
checks if the value of two operands are equal or not, if values are not equal then condition is true ex a is 10 b is 20 (a != b) is true
<,>
checks if the value of either operand is greater than or less than, if yes then condition is true a > b is true a < b is false
<=, >=
checks if the value of either operand is less than/greater than or equal to the other ex. a >= b true a <= b false
<=>
Combined comparison operator. Returns 0 if first operand equals second, 1 if first operand is greater than the second and -1 if first operand is less than the second. ex. (a <=> b) returns -1.
.eql?
True if the receiver and argument have both the same type and equal values. ex. 1 == 1.0 returns true, but 1.eql?(1.0) is false.