# Cannot reassign dict entry with nothing value

**URL:** https://discourse.julialang.org/t/cannot-reassign-dict-entry-with-nothing-value/32321
**Category:** New to Julia
**Created:** [December 16, 2019, 7:53am UTC](https://discourse.julialang.org/t/cannot-reassign-dict-entry-with-nothing-value/32321 "2019-12-16T07:53:58Z")
**Posts on this page:** 1
**Showing post:** 2

<div class="post-metadata">

### Author: ![fredrikekre](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fredrikekre/32/1688_2.png) [@fredrikekre](https://discourse.julialang.org/u/fredrikekre)
#### Post date: [December 16, 2019, 7:58am UTC](https://discourse.julialang.org/t/cannot-reassign-dict-entry-with-nothing-value/32321/2 "2019-12-16T07:58:54Z")

</div>

Your dictionary can only hold keys of type `String` and values of type `Nothing`, as indicated in the output; it is a dictionary of type `Dict{String,Nothing}`. If you want your dictionary to accept, for example, both `nothing` and integers as values you can specify that when constructing the dictionary:

```julia
julia> dict = Dict{String,Union{Nothing,Int}}("A" => nothing)
Dict{String,Union{Nothing, Int64}} with 1 entry:
  "A" => nothing

julia> dict["A"] = 1
1

```

See also [PSA: how to quote code with backticks](https://discourse.julialang.org/t/psa-how-to-quote-code-with-backticks/7530) for how to post code-formatted code (which makes it easier to read).

---

_[View the full topic](https://discourse.julialang.org/t/cannot-reassign-dict-entry-with-nothing-value/32321)._
