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

A Version class includes Comparable and defines <=> as parts <=> other.parts, where parts is the dotted version split into integers. What does Version.new("1.0") == Version.new("1.0.0") return?

class Version include Comparable attr_reader :parts def initialize(s); @parts = s.split(".").map(&:to_i); end def <=>(o); parts <=> o.parts; end end p(Version.new("1.0") == Version.new("1.0.0"))