# Using Dict as value in another dict

**URL:** https://discourse.julialang.org/t/using-dict-as-value-in-another-dict/28543
**Category:** New to Julia
**Created:** [September 8, 2019, 3:03pm UTC](https://discourse.julialang.org/t/using-dict-as-value-in-another-dict/28543 "2019-09-08T15:03:41Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![hasanOryx](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/hasanoryx/32/5373_2.png) [@hasanOryx](https://discourse.julialang.org/u/hasanOryx)
#### Post date: [September 8, 2019, 3:03pm UTC](https://discourse.julialang.org/t/using-dict-as-value-in-another-dict/28543/1 "2019-09-08T15:03:41Z")

</div>

I’m trying to use `Dict` as values in another `Dict` so I wrote the below code, that failed as shown in the comments:

```julia
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
=#
```

---

<div class="post-metadata">

### Author: ![kristoffer.carlsson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kristoffer.carlsson/32/22_2.png) [@kristoffer.carlsson](https://discourse.julialang.org/u/kristoffer.carlsson)
#### Post date: [September 8, 2019, 3:09pm UTC](https://discourse.julialang.org/t/using-dict-as-value-in-another-dict/28543/2 "2019-09-08T15:09:21Z")

</div>

```julia
available_fruits = Dict{String, Dict{String, Bool}}()

```
