[swift-dev] RFC: Adding Optional variants of == for collections to the std lib

Martin Kühl martin.kuehl at gmail.com
Sat Dec 5 14:39:15 CST 2015


On 5 December 2015 at 16:38, Paul Young <paulyoungonline at gmail.com> wrote:
>
> I’d like to get a sense from contributors to the standard library if they feel that the functionality in https://github.com/paulyoung/OptionalEquatableCollection has a place there.
>
> The project provides Optional variants of the existing implementations of the "equal to” operator (==) for Array, Dictionary, and Set.
>
> My question is more concerned with the overall concept as opposed to my particular implementation.


Wouldn’t this be solved automatically if collections of Equatable
could conform to Equatable themselves?
I.e. if this were valid

    extension Array: Equatable where Element: Equatable

then we wouldn’t need more special cases for (combinations of)
containers of Equatable elements, like the collection types currently
are.

(see also rdar://23433955)

Martin


More information about the swift-dev mailing list