JuliaLang/julia

map! only works on AbstractArray

Open

#38,344 opened on Nov 7, 2020

View on GitHub
 (4 comments) (2 reactions) (0 assignees)Julia (5,773 forks)batch import
arraysgood first issuehelp wanted

Repository metrics

Stars
 (48,709 stars)
PR merge metrics
 (Avg merge 20d 6h) (157 merged PRs in 30d)

Description

Any reason for restricting the signature of map! to AbstractArray? I don't see why this shouldn't work:

julia> a, b = [1,2], (3,4)
([1, 2], (3, 4))

julia> map(*, a, b)
2-element Vector{Int64}:
 3
 8

julia> map!(*, a, a, b)
ERROR: MethodError: no method matching map!(::typeof(*), ::Vector{Int64}, ::Vector{Int64}, ::Tuple{Int64, Int64})
Closest candidates are:
  map!(::F, ::AbstractArray, ::AbstractArray) where F at abstractarray.jl:2259
  map!(::F, ::AbstractArray, ::AbstractArray, ::AbstractArray) where F at abstractarray.jl:2303
  map!(::F, ::AbstractArray, ::AbstractArray...) where F at abstractarray.jl:2350
  ...
Stacktrace:
 [1] top-level scope
   @ REPL[12]:1

Contributor guide