#Initializing the 2 structs struct inner value::Float64 end struct outer inner::Any end #Initializing the 2 dictionaries outer_dic = Dict() inner_dic = Dict() #Defining the values for the inner dictionary inner_dic = inner(1) inner_dic = inner(2) inner_dic = inner(3) #Defining the values for the outer dictionary outer_dic = outer([inner_dic,inner_dic,inner_dic]) #Goal #This does not work but this is what I would like to do as simple as possible, preferably without for-loops array = collect(outer_dic.inner[1:3].value)
Extracting elements from dictionary containing a struct, where the struct is made up of a dictionary containing a nested struct
@show getfield.((outer_dic.inner[i] for i in 1:3), :value)
works for me.
Thank you! It works like a charm!
That only extracts a vector of the inner structs, and not the actual values inside the inner structs. But I believe that what goerch suggested works
collect(outer_dic.inner[i].value for i in 1:3)
The above also works and is a pretty clean solution I think!