midSwift
What are closures in Swift?
Updated May 17, 2026
Short answer
Closures are self-contained blocks of functionality.
Deep explanation
They capture values from surrounding context and are heavily used in async programming.
Real-world example
Used in completion handlers for network calls.
Common mistakes
- Retain cycles due to strong references.
Follow-up questions
- What is trailing closure syntax?
- What is capture list?