Curriculum Idioms & ecosystem Defer
Defer
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.
9 ready
01
pick one defer schedules a function call to run when the
02
pick one Multiple defer statements in the same function run in a
03
pick oneWhen are the arguments to a deferred call evaluated?
04
fill blanksType the keyword that schedules a function call to run
05
fill blanks The most common production use of defer is to release a
06
type one line Write the deferred call that prints world AFTER the
07
type one lineDefer-arg-evaluation gotcha from MCQ exercise 3 in action.
08
write a programDemonstrate LIFO ordering of multiple defers.
09
write a programTheme 7.1 capstone — pull together defer + resource