One very common beginner error is being surprised when fill()
creates an array in which every element is the same value. This can cause unexpected behavior when that value is some mutable object (like an Array
), since modifying that value once modifies every entry in the fill
result. For example: Initialization of array of arrays with `fill(ones(1),2,2)`: only one vector is created or fill(anArray,2) behaviour
At its heart, this is just about the fact that Julia does not implicitly copy things like C++ or Matlab would.