=== В Swift
//Triple Equals check that both object's reference is same or not.
class TripleEqualsExample : Equatable {
let value: Int
init(value: Int) {
self.value = value
}
static func == (lhs: TripleEqualsExample, rhs: TripleEqualsExample) -> Bool {
return lhs.value == rhs.value
}
}
let instances1 = TripleEqualsExample(value: 5)
let instances2 = TripleEqualsExample(value: 5)
let instances3 = instances1
if instances1 == instances2 {
print("the two instances are equal!")
}
if instances1 === instances2 {
//It does not enter here
} else {
print("the two instances are not identical!")
}
if instances3 === instances1 {
print("the two instances are identical!")
}
Developer101