JuliaLang/julia

map! only works on AbstractArray

Open

#38.344 aperta il 7 nov 2020

Vedi su GitHub
 (4 commenti) (2 reazioni) (0 assegnatari)Julia (5773 fork)batch import
arraysgood first issuehelp wanted

Metriche repository

Star
 (48.709 star)
Metriche merge PR
 (Merge medio 20g 6h) (157 PR mergiate in 30 g)

Descrizione

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

Guida contributor