# Dictionary lookup errors when the struct contains empty vectors

**URL:** https://discourse.julialang.org/t/dictionary-lookup-errors-when-the-struct-contains-empty-vectors/109965
**Category:** General Usage
**Tags:** question, dictionary
**Created:** [February 9, 2024, 5:13am UTC](https://discourse.julialang.org/t/dictionary-lookup-errors-when-the-struct-contains-empty-vectors/109965 "2024-02-09T05:13:45Z")
**Posts on this page:** 1
**Showing post:** 2

<div class="post-metadata">

### Author: ![oxinabox](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oxinabox/32/206603_2.png) [@oxinabox](https://discourse.julialang.org/u/oxinabox)
#### Post date: [February 9, 2024, 5:17am UTC](https://discourse.julialang.org/t/dictionary-lookup-errors-when-the-struct-contains-empty-vectors/109965/2 "2024-02-09T05:17:54Z")

</div>

SInce you didn’t implement 2 arg hash in code that uses it (like `Dict`) that falls back to the default hash which uses objectref, and so they hash differently

```julia
julia> hash(n_1, UInt(0))
0x416534e228463c4d

julia> hash(n_2, UInt(0))
0x65ee65d3463e8fcc

```

**You need to implement 2 argument `hash`.**  
(don’t implement 1 argument hash)

e.g.

```julia
Base.hash(n::Node, h::UInt) = sum(hash, children(n); init=h) 

```

(I am a little dubious of using `sum` in hash and would consider `reduce(xor`, but that is another discussion)

---

_[View the full topic](https://discourse.julialang.org/t/dictionary-lookup-errors-when-the-struct-contains-empty-vectors/109965)._
