Thanks Michele, I also discovered [(Int64=>Int64)[]] would also do it,
except the returned object contains 1 element:

julia> [(Int64=>Int64)[]]
1-element Array{Dict{Int64,Int64},1}:
 Dict{Int64,Int64}()


On Tue Nov 11 2014 at 3:39:06 PM Michele Zaffalon <
michele.zaffa...@gmail.com> wrote:

> Array(Dict{Int64,Int64},0)
>
> On Tue, Nov 11, 2014 at 7:49 AM, Todd Leo <sliznmail...@gmail.com> wrote:
>
>> How to initialize an array of dicts? Is there any suggested ways to do it?
>>
>> julia> (Int64=>Int64)[]
>> Dict{Int64,Int64} with 0 entries
>>
>> # And since brackets creates Arrays:
>> julia> Any[]
>> 0-element Array{Any,1}
>>
>> # So I suppose this would generate array of dicts, until it fails:
>> julia> ((Int64=>Int64)[])[]
>> ERROR: `getindex` has no method matching getindex(::Dict{Int64,Int64})
>>
>>
>>
>>
>> On Sunday, May 4, 2014 5:02:14 AM UTC+8, thom lake wrote:
>>>
>>> One thing that I like about {} for initializing Array{Any,1}, is the
>>> consistency with comprehension syntax. Namely, braces for Any, brackets for
>>> specific types
>>>
>>> julia> typeof({i=>2i for i = 1:10})
>>> Dict{Any,Any}
>>>
>>> julia> typeof([i=>2i for i = 1:10])
>>> Dict{Int64,Int64}
>>>
>>> julia> typeof({2i for i = 1:10})
>>> Array{Any,1}
>>>
>>> julia> typeof([2i for i = 1:10])
>>> Array{Int64,1}
>>>
>>>
>>>
>

Reply via email to