Hi, I have function update_agent_attributes that accepts a Dict{Symbol, Any} as one of the arguments. However when I pass a Dict{Symbol, Interger} I get an Method Error. Any idea why ?
mutable struct Casualty
id :: Int
pos :: Tuple{Int,Int}
trauma :: Int
awaiting_rescue :: Bool
rescued_by :: Int
end
mutable struct Rescuer
id :: Int
pos :: Tuple{Int, Int}
end
@doc "Update agent attributes" ->
function update_agent_attributes!(agent::Union{Casualty,Rescuer},attr::Dict{Symbol,Any})
for (k,v) in attr
setfield!(agent,k,v)
end
end
c1 = Casualty(1, (7,7), 3, true, 999)
attrs = Dict(:awaiting_recue => false, :rescued_by => 6)
update_agent_attributes!(c1, attrs)
>>>
ERROR: MethodError: no method matching update_agent_attributes!(::Casualty, ::Dict{Symbol, Integer})
Closest candidates are:
update_agent_attributes!(::Union{Casualty, Rescuer}, !Matched::Dict{Symbol, Any}) at ~/github/CRTT-lite/crtt_lite_osm.jl:120