Quantcast
Channel: First steps - JuliaLang
Viewing all articles
Browse latest Browse all 2795

How to avoid supplying exact types in a Dict constructor?

$
0
0

Hi,

When I have a type hierarchy where TC is a concrete implementation of type T and I have defined a struct as follows:

struct Foo
    d::Dict{T,Any}
end

What do I need to do to be able to call the constructor as follows:

Foo(Dict(TC() => value))

Instead of having to call it as:

Foo(Dict{T, Any}(TC() => value))

And what is the logic behind it?

Thanks in advance,
Stef

7 posts - 4 participants

Read full topic


Viewing all articles
Browse latest Browse all 2795