Open hitsvilleusa opened 1 year ago
For collection types like Set
and Dictionary
that are semantically unordered (i.e. their order isn't guaranteed to be the same each time you run a program), any API that requires semantic ordering won't really be usable. The same is true for standard library collection algorithms like starts(with:)
and equalElements(_:)
.
For ordered collections, like strings, arrays, buffers, and many of the collection types in swift-collections, the contains
method works just as you'd expect.
Because this is defined on
Collection
it is available to allCollection
types, not justString
. The behavior on other types is odd at best. It isn't even predictable when working with aSet
. I think it should either be fixed to behave as expected, or narrowed down to just work onString
?Attached is an example playground to experiment with which demonstrates the issue.
Contains.playground.zip