typeover
curriculum

Curriculum Idioms & ecosystem Defer exercise 6 · fill-line

Defer


About this theme

defer fn() schedules fn to run when the surrounding function returns. The closest TS analogue is a try/finally you don't have to indent. Multiple defers run LIFO. Arguments are evaluated at the defer site, not at the call site — a common surprise. Also: defer in a loop accumulates.