Skip to main content
Journey Uncommon Logo
JourneyUncommon
mediumRubyComparable and spaceshipSingle-choice MCQ

A `Money` class includes `Comparable` with a `<=>` based on cents. Two distinct instances both hold 100 cents. What does this output?

class Money include Comparable attr_reader :cents def initialize(c); @cents = c; end def <=>(o); cents <=> o.cents; end end a, b = Money.new(100), Money.new(100) p a == b p a.eql?(b) p({ a => 1 }[b])