Ah yeah this tripped me up at first as well. If you look at the help page for fill:
If x is an object reference, all elements will refer to the same object:
julia> A = fill(zeros(2), 2);
julia> A = 42; # modifies both A and A
All of the objects in A are the same (like pointing exactly to the same spot in memory). So when you update one, they all get updated.
I usually avoid this using a list comprehension:
julia> B = [zeros(2) for _ in 1:3]
julia> B = 5
I think this is a really important thing for people to come to Julia (especially from R) to realize. In Julia, whenever you call f(g(x))f only sees the result of g(x), not how it got there. This is why macros have special syntax. In R, all functions are the equivalent of macros in Julia, which adds a ton of magic that makes code less predictable. In Julia, there is a special syntax that warns the reader that something special is happening when a macro is used.
@Oscar_Smith, could you please explain a bit further what this fill()'s behavior has to do with f(g(x)), and why this is the most logical choice?
It looks like another trap that is very easy to fall into. Thanks.
A = fill([0,0], 3)
A = 5
First, if all you want is a matrix, then fill(0, (2, 3)) suits your need.
If you really want an array of arrays, then you have to create independent arrays for each entry in the larger array (usually with list comprehension).
For your question, fill(, 3) could be interpreted as such:
create an array that repeats a single object
the object is  in this case
this object will be repeated for 3 times
fill does not attempt to make copies of this object
But array comprehension [ for i in 1:3] is not taking  as an argument, instead, it takes a function i-> that produces a distinct array that only contains 1 each time it is called.