Array().fill acts weirdly
If I do matrix[0][0] = "a" in option 1 matrix, it replaces entire 1st column with "a". But that's not the case for option 2, it only only replaces at the specified position.
5 Replies
because you're filling the array with the same reference to the array
you're not filling with 3 different copies of the same array
this is the same as doing this:
oh, and the 2nd one is the equivalent of this:
so, when you change the index on the first, you're actually changing the index on the same array for all
with the same reference
thanks
you're welcome