Broadcast had one job (e.g. broadcasting over iterators and generator)ย #18618
Closed
Description
opened on Sep 21, 2016
It was surprising to find that broadcast
is not working with iterators
dict = Dict(:a => 1, :b =>2)
@show string.(keys(dict)) # => Expected ["a", "b"]
"Symbol[:a,:b]"
This is due to Broadcast.containertype
returning Any
Line 31 in 413ed79
leading to the fallback at:
Line 265 in 413ed79
Defining containertype
to be Array
for that iterator lead to problems with calling size
on it, because broadcast
doesn't check against the iterator interface iteratorsize(IterType)
.
map
solves this with the fallback map(f, A) = collect(Generator(f,A))
which may be more sensible that the current definition of broadcast(f, Any, A) = f(A)
Activity