I think that in 0.4, => is not merely syntax, but a constructor for a
Pair. So you can do

julia> [Pair(i,2*i) for i = 1:3]
3-element Array{Pair{Int64,Int64},1}:
 1=>2
 2=>4
 3=>6

and using the => is just syntactic sugar.

My understanding that [1=>2, 3=>4] is deprecated because it will
eventually construct [Pair(1,2), Pair(3,4)] to be consistent.

(type1=>type2)[...] comprehensions are syntactic sugar for creating
Dicts.

HTH,

Tamas

On Mon, Mar 16 2015, Jim Garrison wrote:

> Bumping this since I am still curious and have been unable to figure out
> the answer.
>
> Is intentional that dict comprehensions (and typed dict comprehensions)
> still use the old syntax for dictionaries?
>
>     julia> (Int=>Int)[i=>i for i in 1:2] == Dict{Int,Int}(1=>1, 2=>2)
>     true
>
> On Thursday, March 12, 2015 at 9:08:56 AM UTC-7, Jim Garrison wrote:
>>
>> It is well known that the dict syntax in 0.4 has changed
>>
>>      julia> [1=>2,3=>4]
>>      WARNING: deprecated syntax "[a=>b, ...]".
>>      Use "Dict(a=>b, ...)" instead.
>>
>> However, I was surprised to notice that a similar syntax still works for
>> dict comprehensions, without warning:
>>
>>      julia> [i => 2i for i = 1:3]
>>      Dict{Int64,Int64} with 3 entries:
>>        2 => 4
>>        3 => 6
>>        1 => 2
>>
>> Is this intentional?
>>

Reply via email to