Reputation: 8352
I am initializing a vector of strings like this
mask = fill(fill(' ', maxx), maxy)
in order to then populate it by setting individual elements:
mask[y][x] = '·'
This doesn't work: I get maxy
times the same string. I guess the outer fill
just creates a list of pointers to the Vector
created by the inner fill
(the documentation of fill!
confirms this explicitly). What should I do instead?
Upvotes: 4
Views: 47
Reputation: 8352
One solution is to use a list comprehension like this:
mask = [fill(' ', maxx) for y in 1:maxy]
(But I'd still be interested to learn whether there is a solution with fill
.)
Upvotes: 4