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

A class includes `Comparable` and defines `<=>`. For two instances where `<=>` returns `nil`, what does `a < b` do?

class Box include Comparable def initialize(v); @v = v; end def <=>(other); @v.is_a?(Integer) && other.instance_variable_get(:@v).is_a?(Integer) ? @v <=> other.instance_variable_get(:@v) : nil; end end puts(Box.new(1) < Box.new("x"))