Skip to content

Instantly share code, notes, and snippets.

@ph3nx
Created January 19, 2014 17:55
Show Gist options
  • Save ph3nx/8508460 to your computer and use it in GitHub Desktop.
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.
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