Protocols and Assumptions
So what’s the solution – should
RangeReplaceableCollectionType
mandate the kind of index validity behaviour ourremove
algorithm relies on? Or are the assumptions invalid and we need a better algorithm? (of which more in a later article) The Swift standard library is still evolving rapidly with each beta so it’s possibly a little early to tell. For now, be careful about the assumptions you make – just because all the current implementations of a particular protocol work a certain way doesn’t mean other implementations will.