Is it possible to initialize a mutable struct with a variable which is a dict.I am trying the following:
mutable struct Global
speciesCnt::Int64
chromosomeCnt::Int64
nodeCnt::Int64
innov_number::Int64
innovations::Dict{(Int64,Int64),Int64}
cf::Config
function Global(cf::Config)
new(0,0,0,0,Dict{(Int64,Int64),Int64}(),cf) # global dictionary
end
end
however, when I run it I get the following error:
LoadError: TypeError: in Type, in parameter, expected Type, got Tuple{DataType,DataType}.
Any help is greatly appreciated. I am using Julia v 1.0
A proper type signature for your dict is:
Dict{Tuple{Int64,Int64},Int64}
The easiest way to learn how type signatures in Julia look like is to create an object of the desired type and use typeof
function to display its type:
julia> typeof(Dict((1,2)=>3))
Dict{Tuple{Int64,Int64},Int64}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With