I’m using a StringArray, and I just noticed that StringArray operator returns a const. It would be nice to be able to do something like array[i][j] = ‘c’;, but it looks like this isn’t possible. I can certainly just use an OwnedArray instead, but I was just wondering if there’s a reason to make it const.
Yes, the reason it’s const is to stop you doing exactly that sort of thing! Mainly because if something gives you a const stringarray, there shouldn’t be any operations possible that can change its contents.
But I guess I could also add a non-const operator that would let you change the string. Can’t think of any reason why not…
(Ah no, I remember why now… If you use an out-of-range index, it has to return an empty string, so that can’t be made writable.)
Okay, fair enough. I only need to do this in one or two spots, so it’s no big deal.