Unexpected behaviour when using ˋrepeatˋ

kinda, yeah, repeat creates a shallow copy:

julia> a=[[3]];

julia> b=copy(a);

julia> push!(b[1], 4);

julia> a
1-element Vector{Vector{Int64}}:
 [3, 4]

you can do something like this instead:

julia> as = [[0.25] for _ = 1:3];

julia> push!(as[1], 2);

julia> as
3-element Vector{Vector{Float64}}:
 [0.25, 2.0]
 [0.25]
 [0.25]
1 Like