# Merging dictionaries indexed by elements of struct type

**URL:** <https://discourse.julialang.org/t/merging-dictionaries-indexed-by-elements-of-struct-type/30499>\
**Category:** General Usage\
**Tags:** dictionary, data\_structures\
**Created:** [October 30, 2019, 3:32pm UTC](https://discourse.julialang.org/t/merging-dictionaries-indexed-by-elements-of-struct-type/30499 "2019-10-30T15:32:12Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![rdeits](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rdeits/32/286_2.png) [@rdeits](https://discourse.julialang.org/u/rdeits)\
**Post date:** [October 30, 2019, 3:57pm UTC](https://discourse.julialang.org/t/merging-dictionaries-indexed-by-elements-of-struct-type/30499/2 "2019-10-30T15:57:52Z")

</div>

It looks like you’re missing a definition of `Base.hash` for your type. From the documentation for `isequal` (which you can read by typing `?isequal`):

```julia
isequal is the comparison function used by hash tables (Dict). isequal(x,y) must imply that hash(x) == hash(y).

```

Since your `isequal` and `==` tests just check the `v` member, you can do the same for hashing:

```julia
julia> Base.hash(v::my_vector, seed::UInt) = hash(v.v, seed)

```

Also, please quote your code so that it is easier to read. You can find some helpful instructions on how to do that here: [Please read: make it easier to help you](https://discourse.julialang.org/t/psa-make-it-easier-to-help-you/14757)

---

_[View the full topic](https://discourse.julialang.org/t/merging-dictionaries-indexed-by-elements-of-struct-type/30499)._
