# When to use broadcasting with . vs map

**URL:** <https://discourse.julialang.org/t/when-to-use-broadcasting-with-vs-map/58078>\
**Category:** General Usage\
**Tags:** broadcast\
**Created:** [March 27, 2021, 2:05pm UTC](https://discourse.julialang.org/t/when-to-use-broadcasting-with-vs-map/58078 "2021-03-27T14:05:43Z")\
**Posts on this page:** 1\
**Showing post:** 9

<div class="post-metadata">

**Author:** ![goretkin](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/goretkin/32/167_2.png) [@goretkin](https://discourse.julialang.org/u/goretkin)\
**Post date:** [March 28, 2021, 5:06pm UTC](https://discourse.julialang.org/t/when-to-use-broadcasting-with-vs-map/58078/9 "2021-03-28T17:06:06Z")

</div>

If there are multiple arguments, then the behavior of broadcasting and `map` are quite different:

Broadcasting does… broadcasting, and `map` does not:

```julia
julia> [1] .+ [1, 2, 3]
3-element Array{Int64,1}:
 2
 3
 4

julia> map(+, [1], [1, 2, 3])
1-element Array{Int64,1}:
 2

julia> [1, 1] .+ [1, 2, 3]
ERROR: DimensionMismatch("arrays could not be broadcast to a common size; got a dimension with lengths 2 and 3")

julia> map(+, [1, 1], [1, 2, 3])
2-element Array{Int64,1}:
 2
 3

```

Also, broadcasting has some “symbolic” definitions for some types:

```julia
julia> (1:5) .+ (1:5)
2:2:10

julia> map(+, 1:5, 1:5)
5-element Array{Int64,1}:
  2
  4
  6
  8
 10

```

Unfortunately I don’t think there is yet a “standard” multi-argument “map” that is requires the arguments to have the same indices. (I asked [here](https://discourse.julialang.org/t/match-exact-axes-something-more-strict-than-broadcasting-or-map/41206).)

---

_[View the full topic](https://discourse.julialang.org/t/when-to-use-broadcasting-with-vs-map/58078)._
