← Back to archive

Stdle #20 · classes · 2026-06-26

What does this Ruby snippet output?

A past puzzle — fully playable. 4 attempts, hints on wrong guesses.

Point = Data.define(:x, :y)
p = Point.new(x: 3, y: 4)
case p
in Point[x: 0, y:]
puts "on y-axis: #{y}"
in Point[x:, y: 0]
puts "on x-axis: #{x}"
in Point[x:, y:]
puts "#{x},#{y}"
end
Classes
4 attempts left

Answer & explanation