# Julia dict and haskey

**URL:** https://discourse.julialang.org/t/julia-dict-and-haskey/93621
**Category:** New to Julia
**Created:** [January 27, 2023, 10:55am UTC](https://discourse.julialang.org/t/julia-dict-and-haskey/93621 "2023-01-27T10:55:34Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![ditfurth](https://avatars.discourse-cdn.com/v4/letter/d/3e96dc/32.png) [@ditfurth](https://discourse.julialang.org/u/ditfurth)
#### Post date: [January 27, 2023, 10:55am UTC](https://discourse.julialang.org/t/julia-dict-and-haskey/93621/1 "2023-01-27T10:55:34Z")

</div>

Hi all,

I am reading the documentation of Dict and haskey(), but I cannot figure this out.

I want to create a dictionary, where I want to be able to feed in an Integer, and then get the corresponding Float64.

Thus, I define:

```julia
s = Dict{Int, Float64}
const y = 3

haskey(s, y)

```

This gives me an error: MethodError: no method matching haskey(::Type{Dict{Int64, Int64}}, ::Int64)

Why is that? In my view, it should give me false, as the dictionary is empty and does not contain the integer 3 to look up.

Thanks!

---

<div class="post-metadata">

### Author: ![oheil](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oheil/32/220745_2.png) [@oheil](https://discourse.julialang.org/u/oheil)
#### Post date: [January 27, 2023, 10:59am UTC](https://discourse.julialang.org/t/julia-dict-and-haskey/93621/2 "2023-01-27T10:59:12Z")

</div>

Your `s` is only the type, not a Dict itself. Try:

```julia
s = Dict{Int, Float64}()
const y = 3

haskey(s, y)

```

Note the additional `()` after `Dict{Int, Float64}`.

---

<div class="post-metadata">

### Author: ![ditfurth](https://avatars.discourse-cdn.com/v4/letter/d/3e96dc/32.png) [@ditfurth](https://discourse.julialang.org/u/ditfurth)
#### Post date: [January 27, 2023, 11:00am UTC](https://discourse.julialang.org/t/julia-dict-and-haskey/93621/3 "2023-01-27T11:00:39Z")

</div>

I see, of course, that makes so much sense. I must have overlooked that detail, thanks for pointing it out
