Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Map do not work for dictionaries in 0.5 #17714

Closed
dhoegh opened this issue Jul 30, 2016 · 4 comments
Closed

Map do not work for dictionaries in 0.5 #17714

dhoegh opened this issue Jul 30, 2016 · 4 comments
Milestone

Comments

@dhoegh
Copy link
Contributor

dhoegh commented Jul 30, 2016

It seems to be a regression that dictionaries cannot be mapped anymore. The input below works fine in 0.4.

julia> d=[i=>i+1 for i=1:10]
julia> map((x)->"$(x[1])=>$(x[2])",d) # Works in 0.4 but throws a method error in 0.5
ERROR: MethodError: no method matching similar(::Dict{Int64,Int64}, ::Type{String})
julia> map((x)->println("$(x[1])=>$(x[2])"),d) # Works in 0.4 but throws a method error in 0.5
ERROR: MethodError: no method matching similar(::Dict{Int64,Int64}, ::Type{Void})
@tkelman tkelman added the regression Regression in behavior compared to a previous version label Jul 30, 2016
@JeffBezanson
Copy link
Member

map now does this:

julia> map(x->2x[1]=>x[2], Dict(1=>2, 2=>3))
Dict{Int64,Int64} with 2 entries:
  4 => 3
  2 => 2

If you want an array, I think it's better to use a comprehension for that.

@tkelman
Copy link
Contributor

tkelman commented Aug 1, 2016

This change should be documented as breaking and added to NEWS

@tkelman tkelman added needs docs Documentation for this change is required and removed regression Regression in behavior compared to a previous version labels Aug 1, 2016
@tkelman tkelman added this to the 0.5.0 milestone Aug 1, 2016
@StefanKarpinski
Copy link
Member

Speaking of which, I don't think the new Dict(k(x) => v(x) for x in itr) is in NEWS, is it?

JeffBezanson added a commit that referenced this issue Aug 1, 2016
@tkelman tkelman removed the needs docs Documentation for this change is required label Aug 1, 2016
@tkelman
Copy link
Contributor

tkelman commented Aug 1, 2016

closed by fc3cbc9 ? @dhoegh leave a comment if you disagree and we can reopen if there's anything else needed here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants