Skip to content

Instantly share code, notes, and snippets.

@samsm
samsm / comparable.rb
Last active November 29, 2023 17:17
Ruby Comparable and Range!
# I was familiar with this, the keys here are "include Comparable" and the <=> method.
# <=> return 1 for larger, 0 for equal, -1 for smaller than "other"
class UndergradClassification
include Comparable
CLASSIFICATIONS = ["freshman", "sophomore", "junior", "senior"]
attr_reader :name, :index
def initialize(name)