Comparison Operators Flashcards

You may prefer our related Brainscape-certified flashcards:
1
Q

==

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

!=

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

<,>

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

<=, >=

A

checks if the value of either operand is less than/greater than or equal to the other ex. a >= b true a <= b false

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

<=>

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

.eql?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly