# Why doesn't \`broadcast\` work with anonymous functions?

**URL:** <https://discourse.julialang.org/t/why-doesnt-broadcast-work-with-anonymous-functions/5085>\
**Category:** General Usage\
**Tags:** broadcast\
**Created:** [July 27, 2017, 3:45am UTC](https://discourse.julialang.org/t/why-doesnt-broadcast-work-with-anonymous-functions/5085 "2017-07-27T03:45:52Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![tparker](https://avatars.discourse-cdn.com/v4/letter/t/839c29/32.png) [@tparker](https://discourse.julialang.org/u/tparker)\
**Post date:** [July 27, 2017, 3:45am UTC](https://discourse.julialang.org/t/why-doesnt-broadcast-work-with-anonymous-functions/5085/1 "2017-07-27T03:45:52Z")

</div>

```
evaluate(f, x::Int64) = f(x);
evaluate.(x -> x^2, [1, 2, 3])

```

Gives the error `MethodError: no method matching size(::##1#2)`. What’s wrong with the above code? I’m using version 0.5.0.

---

<div class="post-metadata">

**Author:** ![Ralph\_Smith](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ralph_smith/32/10344_2.png) [@Ralph\_Smith](https://discourse.julialang.org/u/Ralph_Smith)\
**Post date:** [July 27, 2017, 4:01am UTC](https://discourse.julialang.org/t/why-doesnt-broadcast-work-with-anonymous-functions/5085/2 "2017-07-27T04:01:03Z")

</div>

With 0.6.0:

```julia
julia> evaluate(f,x)=f(x)
evaluate (generic function with 1 method)

julia> evaluate.(x->x^2,[1,2,3])
3-element Array{Int64,1}:
 1
 4
 9

```

---

<div class="post-metadata">

**Author:** ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)\
**Post date:** [July 27, 2017, 4:08am UTC](https://discourse.julialang.org/t/why-doesnt-broadcast-work-with-anonymous-functions/5085/3 "2017-07-27T04:08:09Z")

</div>

It was only in 0.6 that `broadcast` was extended to treat objects as a “scalar” by default (except for a few container types like arrays and tuples), allowing it to work on non-numeric arguments.
