Cannot reassign dict entry with nothing value

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> 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 for how to post code-formatted code (which makes it easier to read).

3 Likes