Hi,
The following works:
function Price(components::Dict{String, <:Real}; precision::Integer = 2)
price = Price(precision = precision)
for entry in keys(components)
price.components[entry] = round(components[entry], digits = precision)
end
return price
end
Price(components::AbstractVector{<:Pair{String, <:Real}}; precision::Integer = 2) = Price(Dict{String, Float64}(components), precision = precision)
You used key instead of entry and your AbstractVector needs to be of <:Pairs.