Julia optimistically types your arrays and dictionaries, but you can always 
specify it explicitly:

Stimuli = Dict{ASCIIString, Any}[Dict("slots" => Dict("name"=> i,"list"=> 1
)) for i = 1:10]



On Saturday, August 6, 2016 at 9:16:56 AM UTC-4, Christopher Fisher wrote:
>
> Hi all-
>
> I'm trying to create an Array of Dict{ASCIIString,Any}. What I have right 
> now is similar to this:
>
> Stimuli = [Dict("slots" => Dict("name"=> i,"list"=> 1)) for i = 1:10]
>
> I want to build in the flexibility so I can add an entry later in the code:
>
> Stimuli[1]["time"] = .234
>
> but I get the following error because its the wrong type
>
> MethodError: `convert` has no method matching 
> convert(::Type{Dict{ASCIIString,Int64}}, ::Float64)
>
> I could add a fake entry to allow future additions:
>
> Stimuli = [Dict("slots" => Dict("name"=> i,"list"=> 1), "fakeEntry" => 1) 
> for i = 1:10]
> Stimuli[1]["time"] = .234
> 0.234
>
> This works but it is not ideal to populate the dictionary with extraneous 
> entries.  What is the proper way to create an Array of 
> Dict{ASCIIString,Any}?
>
> Thanks,
>
> Chris 
>

Reply via email to