Deprecate dict comprehension construction in favor for Generator #16510
Closed
Description
opened on May 22, 2016
As the new Generator syntax matches nicely with the construction of dictionaries. I propose using generators instead of using the comprehensions syntax to construct dictionaries as the generator syntax is closer to the syntax for manually initialization of the dictionaries. This should be deprecated:
julia> [i=>i*2 for i=1:2]
Dict{Int64,Int64} with 2 entries:
2 => 4
1 => 2
In favor for:
julia> Dict(i=>i*2 for i=1:2)
Dict{Int64,Int64} with 2 entries:
2 => 4
1 => 2
The deprecation will match the deprecation in:
julia> [1=>2, 2=>4]
WARNING: deprecated syntax "[a=>b, ...]" at REPL[53]:1.
Use "Dict(a=>b, ...)" instead.
Dict{Int64,Int64} with 2 entries:
2 => 4
1 => 2
Metadata
Assignees
Labels
No labels
Activity