Skip to content

Instantly share code, notes, and snippets.

@vochicong
Created December 9, 2017 05:38
Show Gist options
  • Save vochicong/c01d55a89a76d629c6cff7701100c5d8 to your computer and use it in GitHub Desktop.
Save vochicong/c01d55a89a76d629c6cff7701100c5d8 to your computer and use it in GitHub Desktop.
BleakWanZebrafinch created by anonymous - https://repl.it/repls/BleakWanZebrafinch
3 <=> 4
3 > 4
Class Steak
include Comparable
attr_accessor grade
GRADES = { prime: 1, choice: 2, select: 3 }
def <=>(other)
if GRADES[self.grade] < GRADES[other.grade]
-1
elsif GRADES[self.grade] == GRADES[other.grade]
0
else
1
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment