Thank you for the reply.

I do find this unsatisfying, because by the same logic I would expect
`[i=>i for i in 1:2]` to create an array of pairs in the future.  But
the syntax currently creates a dictionary and does not seem to be
deprecated.  In fact, there seems to be no dict comprehension syntax
consistent with the new dict construction syntax (i.e. that uses
`Dict`), as far as I can tell.


On 03/15/2015 11:55 PM, Tamas Papp wrote:
> 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