๐ WAYPOINT LESSON
Checkpoint โ Delegates & Capture
โญโญ intermediateโณ 20 min read๐ Lesson 97 of 265
Counter factories, capture-debugging, and a callback-driven command router in one graded unit.
The gate
Three functions, one graded unit:
MakeAccumulator(int seed)returns aFunc<int, int>that adds its argument to a private running total (starting at seed) and returns the new total. Two accumulators are independent.SumActions(params Action[] steps)returns an Action that runs every step in order โ twice if a step appears twice, skipping nulls safely.Route(string command, int value)โ a table-driven router over registered commands (register viaRegisterCommand(name, Func<int,int>)); unknown command returns -1, known ones apply their function.
Capture semantics decide all three.