Created
January 19, 2014 17:55
-
-
Save ph3nx/8508460 to your computer and use it in GitHub Desktop.
The combined comparison operator is used to compare two objects in Ruby. It returns 0 if they are the same. 1 if the first operand is greater and -1 if it's less.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
a1 = "A Test" | |
a2 = "A Boom" | |
a1 <=> a2 | |
# => 1 | |
b1 = "2" | |
b2 = "9" | |
b1 <=> b2 | |
# => -1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment