I don't understand the following behaviour:
struct MyVec
v::Vector{Int}
end
Base.getindex(v::MyVec, i...) = getindex(v.v, i...)
Base.setindex!(v::MyVec, x, i...) = setindex!(v.v, x, i...)
v = MyVec([1, 2, 3]) # [1, 2, 3] ok.
v[1:2] = [4, 5] # [4, 5, 3] ok.
v[1:2] .= [6, 7] # [4, 5, 3] still.. why?
Can someone explain why =
mutates v.v
and not .=
here?
Not sure exactly, but it's got something to do with how broadcasting is not implemented correctly for non-arrays.
Nonetheless, I believe this is a bug. I would make an issue
Thank you. Cross-referencing here: https://github.com/JuliaLang/julia/issues/59115.
Last updated: Aug 14 2025 at 04:51 UTC