← Back to archive

Stdle #79 · comparisons · 2026-08-24

What does this Ruby snippet output?

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

vals = [1, "two", :three, 4.0]
vals.each do |v|
case v
in Integer => n
puts "int:#{n}"
in String => s
puts "str:#{s}"
in Symbol => sym
puts "sym:#{sym}"
in Float => f
puts "float:#{f}"
end
end
Comparisons
4 lines
4 attempts left

Answer & explanation