Skip to main content
Journey Uncommon Logo
JourneyUncommon
hardGoescape analysisSingle-choice MCQ

Examine this loop. From an escape-analysis perspective, why does the closure's capture force a heap allocation?

func makeFns() []func() int { var fns []func() int for i := 0; i < 3; i++ { fns = append(fns, func() int { return i }) } return fns }