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


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.


With 0.6.0:

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}:


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.