← Back to archive

Stdle #73 · blocks · 2026-08-18

What does this Ruby snippet output?

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

def run1
yield 2 if block_given?
end
def run2(&b)
b.call(2) if b
end
puts run1 { |x| x * 5 }
puts run2 { |x| x * 5 }
Blocks
2 lines
4 attempts left

Answer & explanation