# Create a set with custom hash and isequal

**URL:** <https://discourse.julialang.org/t/create-a-set-with-custom-hash-and-isequal/127862>\
**Category:** General Usage\
**Tags:** set, hash\
**Created:** [April 8, 2025, 8:08pm UTC](https://discourse.julialang.org/t/create-a-set-with-custom-hash-and-isequal/127862 "2025-04-08T20:08:07Z")\
**Posts on this page:** 1\
**Showing post:** 7

<div class="post-metadata">

**Author:** ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)\
**Post date:** [April 9, 2025, 3:07pm UTC](https://discourse.julialang.org/t/create-a-set-with-custom-hash-and-isequal/127862/7 "2025-04-09T15:07:04Z")

</div>

> [@jlbosse](#):
>
> Is it possible to create a `Set{MyType}` that uses a custom `hash` and `isequal` functions

See:

> [@Dictionary with custom hash function](https://discourse.julialang.org/t/dictionary-with-custom-hash-function/49168/4):
>
> Just wrap your keys in a new type: struct MyKey val::UInt end Base.hash(a::MyKey, h::UInt) = xor(a.val, h) Base.(==)(a::MyKey, b::MyKey) = a.val == b.val

---

_[View the full topic](https://discourse.julialang.org/t/create-a-set-with-custom-hash-and-isequal/127862)._
