Is it possible to get the retain count of a Closure in Swift?

Closure contexts are themselves immutable, so whether they're value types or reference types is somewhat moot. When they capture mutable variables, they do so as if a struct contained a class reference—the struct itself has value semantics, but references mutable data elsewhere. In some ways, closures are more like value types, because the language does not guarantee that closures have a stable identity, unlike class objects.

4 Likes