I’m trying to use Dict
as values in another Dict
so I wrote the below code, that failed as shown in the comments:
fruits = ["apple", "orange", "banana"]
#=
3-element Array{String,1}:
"apple"
"orange"
"banana"
=#
fruits_matrix = Dict(fruits .=> false)
#=
Dict{String,Bool} with 3 entries:
"orange" => false
"banana" => false
"apple" => false
=#
available_fruits = Dict{String, Dict{String, Bool}}
#=
Dict{String,Dict{String,Bool}}
=#
available_fruits["home"] = fruits_matrix
#= Failed with error:
MethodError: no method matching setindex!(::Type{Dict{String,Dict{String,Bool}}}, ::Dict{String,Bool}, ::String)
Stacktrace:
[1] top-level scope at In[108]:1
=#
push!(available_fruits, "home" => fruits_matrix)
#= Failed with error:
MethodError: no method matching push!(::Type{Dict{String,Dict{String,Bool}}}, ::Pair{String,Dict{String,Bool}})
Closest candidates are:
push!(::Any, ::Any, !Matched::Any) at abstractarray.jl:2159
push!(::Any, ::Any, !Matched::Any, !Matched::Any...) at abstractarray.jl:2160
push!(!Matched::Array{Any,1}, ::Any) at array.jl:859
...
Stacktrace:
[1] top-level scope at In[109]:1
=#