Hi Dennis,

See comments below:

> When defining a Dict with brackets like so [1 => Client(1,"Julia")] 
> everything works,
> but not if I define it via Dict{Int64,Client}
> 
> I get the same type at creation time 
> Dict{Int64,Client} (constructor with 2 methods)
> 
> but later when I check again I get DataType
> typeof(Clients)
> DataType

As I’ll note below, you’re actually setting Clients to be a type, not a value. 
So this is why things seem to disagree.


> 
> What am I doing wrong?
> An IJulia file is attached to this message.
> 
> 
> type Client
>     id::Int64
>     name
> end
> 
> This works:
> Clients = [1 => Client(1,"Julia")]
> 

Yes, this is the way to create Dict you’re looking.

> This does not work 
> Clients = (Int64, Client)
> 

This creates a tuple containing two types. Not so useful to you.


> This should work I think, but does not work either
> Clients = Dict{Int64,Client}

This is super close to working, but you’re missing parentheses: you want 
`Clients = Dict{Int64, Clien}()`. What you’ve done right now is name the type, 
but not constructed an instance of it.

To make that clear, think of the following:

type Foo
        a::Int
end

x = Foo
y = Foo(1)

You’re doing the `x = Foo` line, but you want the `y = Foo(1)` line.

Reply via email to