-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Description
Original Title: Change fill([0, 0], 2) behavior for 2.0
The behavior of fill when its first argument is an array is to create an array of arrays, where each of the elements is a reference to the exact same array in memory. This is counterintuitive to many users (see Discourse links below), and it seems kind of pointless. I propose that in 2.0 fill with an array input should fill the resulting array with copies of the input array.
Below are some examples where this came up on Discourse. There may be more.
https://discourse.julialang.org/t/simple-question-about-assignment-to-a-vector-of-vectors/62744
https://discourse.julialang.org/t/fill-anarray-2-behaviour/22429
https://discourse.julialang.org/t/initialization-of-array-of-arrays-with-fill-ones-1-2-2-only-one-vector-is-created/48048
https://discourse.julialang.org/t/how-can-i-fill-an-array-with-empty-2d-arrays/60895