Broadcasting warning

I got a warning when trying to do some broadcasting:

julia> 5.0 .* a
┌ Warning: broadcast will default to iterating over its arguments in the future. Wrap arguments of
│ type `x::mystruct` with `Ref(x)` to ensure they broadcast as "scalar" elements.
│   caller = ip:0x0
└ @ Core :-1

where a is a mystruct typed object.

what does the warning mean? how could I get rid of it? thanks.

Use 5.0 .* (a,) or 5.0 .* Ref(a) or define Base.broadcastable(a::A) = Ref(a)

2 Likes

thanks.

but … what does it mean???:thinking:

It means that broadcasting will default to iterating instead of treating it as a scalar in 1.0.

@kristoffer.carlsson: I am on Julia 1.0 win 10 environment. Here is what I get.

julia> a=[1,2,3,4,5]
5-element Array{Int64,1}:
 1
 2
 3
 4
 5

julia> 5.0 .*a
5-element Array{Float64,1}:
  5.0
 10.0
 15.0
 20.0
 25.0

julia> a=(1,2,3,4,5)
(1, 2, 3, 4, 5)

julia> 5.0 .*a
(5.0, 10.0, 15.0, 20.0, 25.0)

Sure but the first post said