Closures are used heavily in Swift APIs for callbacks, collection operations, and asynchronous work. Interviewers ask this to test whether you understand closure lifetime, compiler rules, and memory implications.
Explain the difference between escaping and non-escaping closures in Swift.
Your answer should address:
@escaping is required in some function parametersselfThe expected depth is practical language understanding rather than compiler internals. You should define both terms clearly, explain when the compiler requires @escaping, and mention the relationship to asynchronous execution, stored callbacks, and retain-cycle risk.