Building a Custom Collection with Protocols in Swift |

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

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.