← Back to archive

Stdle #24 · hashes · 2026-06-30

What does this Ruby snippet output?

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

h = Hash.new { |hash, key| hash[key] = [] }
h[:a] << 1
h[:a] << 2
h[:b] << 3
puts h[:a].inspect
puts h[:b].inspect
puts h[:c].inspect
Hashes
3 lines
4 attempts left

Answer & explanation