You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Because this is defined on Collection it is available to all Collection types, not just String. The behavior on other types is odd at best. It isn't even predictable when working with a Set. I think it should either be fixed to behave as expected, or narrowed down to just work on String?
Attached is an example playground to experiment with which demonstrates the issue.
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
The text was updated successfully, but these errors were encountered: