Stdle #136 · comparisons · 2026-10-20
What does this Ruby snippet output?
A past puzzle — fully playable. 4 attempts, hints on wrong guesses.
Rectangle = Struct.new(:width, :height) do include Comparable def <=>(other) area <=> other.area end def area width * height endendr1 = Rectangle.new(2, 5)r2 = Rectangle.new(3, 4)puts r1 > r2puts r1 < r2puts [Rectangle.new(3,3), Rectangle.new(2,6), Rectangle.new(1,10)].min.to_a.inspectComparisons