Easy: class SomeClass : Equatable {

-- 
Adrian Zubarev
Sent with Airmail

Am 9. Juli 2017 um 17:11:14, David Baraff via swift-users 
(swift-users@swift.org) schrieb:

Given 2-tuples of type (T1, T2), you should be able to invoke the == operator 
if you could on both types T1 and T2, right?  i.e.

(“abc”, 3) == (“abc”, 4) // legal

but:

class SomeClass {
    static public func ==(_ lhs:SomeClass, _ rhs:SomeClass) -> Bool {
        return lhs === rhs
    }
}

let c1 = SomeClass()
let c2 = SomeClass()

let t1 = ("abc", c1)
let t2 = ("abc", c2)

c1 == c2 // legal
t1 == t2 // illegal




Why is t1 == t2 not legal given that c1 == c2 IS legal?


_______________________________________________
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users
_______________________________________________
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users

Reply via email to