The returned closure shares the captured called flag and result value across every invocation, implementing run-once memoization. The first init() runs fn (incrementing n to 1) and caches the result, while the second init() short-circuits to the cached 1 without calling fn again, so n remains 1. Closed-over flags like this are how once/memoize wrappers remember whether the underlying work already happened.