-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Closed
Labels
broadcastApplying a function over a collectionApplying a function over a collection
Milestone
Description
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
| containertype(::Type) = Any |
leading to the fallback at:
Line 265 in 413ed79
| @inline broadcast_c(f, ::Type{Any}, a...) = f(a...) |
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)
ararslan, andyljones and schneiderfelipe
Metadata
Metadata
Assignees
Labels
broadcastApplying a function over a collectionApplying a function over a collection