Read Different flavors of type erasure in Swift by John Sundell. It refined my understanding of Swift protocols having Self or associated type requirements and what makes Swift protocols different from Objective-C ones.

Post explains three flavors of type erasure:

  • Generic wrapper types;
  • Type erasure with closures; 👈🏿 I favor this.
  • External specialization.

Read Avoiding race conditions in Swift by John Sundell because previous post had a link to it.