Returns a Boolean value indicating whether two references point to the same object instance.
- Xcode 7.1+
- Swift Standard Library
A reference to compare.
Another reference to compare.
This operator tests whether two instances have the same identity, not the same value. For value equality, see the equal-to operator (
==) and the
The following example defines an
Integer type, an integer type with reference semantics.
Integer is a class, its instances can be compared using the identical-to operator (
===). In addition, because
Integer conforms to the
Equatable protocol, instances can also be compared using the equal-to operator (
The identical-to operator (
false when comparing two references to different object instances, even if the two instances have the same value.