Building a Custom Collection with Protocols in Swift | raywenderlich.com

In this Swift tutorial, you’ll learn how to use collection protocols to create your own implementation of a Bag collection type.


This is a companion discussion topic for the original entry at https://www.raywenderlich.com/10286147-building-a-custom-collection-with-protocols-in-swift

How do you access an element via subscripting? I would expect if I have a Bag I could use something like myBag["thisKey"] to get the count, but I get an error trying to use a string.