Thursday, September 29, 2016

What’s in a Swift Collection?

Ole Begemann:

Collections in Swift are very powerful but also very complex. If you want to implement your own custom collection type, you need to understand how the Collection protocol works. And even if all you want to do is use the familiar collection types from the standard library, we think it’s worth learning how things work, not least because it can be a big help in decoding what the compiler wants to tell you with its error messages.

In this article, we’d like to discuss the Collection protocol’s associated types. This might seem like an obscure topic, but we think understanding what the associated types do and why they are needed is key to understanding collections in Swift.

Comments RSS · Twitter

Leave a Comment