[swift-evolution] Proposal: Allow comparisons of arrays possibly containing nil

T.J. Usiyan griotspeak at gmail.com
Fri Jan 1 13:09:38 CST 2016


Does this work for now?

func ==<T : Equatable>(lhs:[T?], rhs: [T?]) -> Bool {
    let zipped = Zip2Sequence(lhs, rhs)

    return zipped.reduce(true) { (old, tuple) in
        old && (tuple.0 == tuple.1)
    }
}


On Fri, Jan 1, 2016 at 12:32 PM, Amir Michail via swift-evolution <
swift-evolution at swift.org> wrote:

> Example:
>
> [Int?]([1,2,nil]) == [Int?]([1,2,nil])
>
> This currently results in: “binary operator '==' cannot be applied to two
> '[Int?]' operands"
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160101/86fcce73/attachment.html>


More information about the swift-evolution mailing list