# In what case \`x===y\` and \`objectid(x) == objectid(y)\` are not interchangable?

**URL:** <https://discourse.julialang.org/t/in-what-case-x-y-and-objectid-x-objectid-y-are-not-interchangable/123265>\
**Category:** General Usage\
**Tags:** dictionary, isequal, hash\
**Created:** [November 29, 2024, 8:30pm UTC](https://discourse.julialang.org/t/in-what-case-x-y-and-objectid-x-objectid-y-are-not-interchangable/123265 "2024-11-29T20:30:28Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![frankwswang](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/frankwswang/32/18561_2.png) [@frankwswang](https://discourse.julialang.org/u/frankwswang)\
**Post date:** [November 29, 2024, 8:30pm UTC](https://discourse.julialang.org/t/in-what-case-x-y-and-objectid-x-objectid-y-are-not-interchangable/123265/1 "2024-11-29T20:30:28Z")

</div>

I was reading the official documentation and found the following statement about [`objectid`](https://docs.julialang.org/en/v1/base/base/#Base.objectid):

> If `x === y` then `objectid(x) == objectid(y)` , and usually when `x !== y` , `objectid(x) != objectid(y)` .

It seems that there are edge cases where `objectid(x) == objectid(y)` does not imply `x===y`.

Does anyone know when this can happen (aside from redefining methods for `==`)? Thanks!

---

<div class="post-metadata">

**Author:** ![jakobjpeters](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jakobjpeters/32/207797_2.png) [@jakobjpeters](https://discourse.julialang.org/u/jakobjpeters)\
**Post date:** [November 29, 2024, 9:16pm UTC](https://discourse.julialang.org/t/in-what-case-x-y-and-objectid-x-objectid-y-are-not-interchangable/123265/2 "2024-11-29T21:16:37Z")

</div>

The `objectid` is a hash value, which has the same limitation as other hash values. That is, there are a potentially infinite number of values but only a finite number of `UInt` hashes. This edge case would then be a hash collision, where two unique values happen to have the same hash.

---

<div class="post-metadata">

**Author:** ![frankwswang](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/frankwswang/32/18561_2.png) [@frankwswang](https://discourse.julialang.org/u/frankwswang)\
**Post date:** [November 29, 2024, 11:35pm UTC](https://discourse.julialang.org/t/in-what-case-x-y-and-objectid-x-objectid-y-are-not-interchangable/123265/3 "2024-11-29T23:35:00Z")

</div>

Thanks! This makes sense. Does `===` double-check the identity of two comparing objects even if their hash values obtained from `objectid` are the same?

---

<div class="post-metadata">

**Author:** ![jakobjpeters](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jakobjpeters/32/207797_2.png) [@jakobjpeters](https://discourse.julialang.org/u/jakobjpeters)\
**Post date:** [November 29, 2024, 11:42pm UTC](https://discourse.julialang.org/t/in-what-case-x-y-and-objectid-x-objectid-y-are-not-interchangable/123265/4 "2024-11-29T23:42:25Z")

</div>

You’re welcome! For some definition of “identity” (as defined by the `===` docstring), yes!
