Two ways of capturing self strongly within a closure
How to use either explicit self references or a capture list to capture self strongly within an escaping Swift closure.
Articles, podcasts and news about Swift development, by John Sundell.
How to use either explicit self references or a capture list to capture self strongly within an escaping Swift closure.
This week, let’s take a look at the various ways that Swift closures can capture the objects and values that they depend on, and how we can control those mechanics.
Predicates can enable us to filter various collections in ways that are incredibly flexible. Let’s take a look at how we could construct powerful, type-safe predicates using closures, generics, and operators.
Let’s take a look at a few different techniques that can let us achieve a nice balance between code reuse and configurability, by building lightweight abstractions that enable us to encapsulate our configuration code.
A look at a few different ways that closures can be defined and used in Swift, the flexibility of Swift’s closure syntax, and how behaviors like escaping and capturing may impact our code.
Even though closures are very widely used, there's a lot of behaviors and caveats to keep in mind when using them. This week, let's take a closer look at closures, how capturing works and some techniques that can make handling them easier.
How type erasure can be implemented using closures, and how it can help you work around using protocols with self or associated type requirements.