Stdle #55 · classes · 2026-07-31
What does this Ruby snippet output?
A past puzzle — fully playable. 4 attempts, hints on wrong guesses.
class Weight include Comparable def initialize(kg) = @kg = kg def <=>(other) = @kg <=> other.instance_variable_get(:@kg) def to_s = "#{@kg}kg"endw = [Weight.new(10), Weight.new(5), Weight.new(8)]puts w.sort.map(&:to_s).inspectputs w.min.to_sClasses