[swift-users] Type "T?" does not conform to protocol 'Equatable'

Rudolf Adamkovič salutis at me.com
Mon Feb 29 08:24:15 CST 2016


Hi everyone!

I have a generic class similar to this one:

class C<T: Equatable> {
    let t: T
    init(t: T) { self.t = t }
}

When try to wrap ‘Int?' inside, I get the following error:

let a = C<Int?>(t: nil) // ERROR: Type "Int?" does not conform to protocol 'Equatable'

Yet when I try to compare two ‘Int?’ values, everything works:

let a: Int? = 5
let b: Int? = 6

let c = a == b // NO ERROR

So, is ‘Int?' equatable or not?

Thanks!

R+
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20160229/9d1d279b/attachment.html>


More information about the swift-users mailing list