Changing elements during foreach

qznc qznc at web.de
Mon Oct 21 12:16:00 PDT 2013


On Monday, 21 October 2013 at 16:22:29 UTC, Krzysztof Ciebiera 
wrote:
> I understand slices now and I don't find it consistent with "no 
> shoot in the foot by default" statement.

I agree. The pitfalls are well understood, yet everybody seems to 
love them. Ok, compared to C array they are an improvement due to 
bounds checking. If the elements are const or immutable (string) 
everything is fine, but write+append is basically 
implementation-defined behavior.

Once there is a proper std.collections, I will probably adapt my 
tutorial to recommend a safe alternative (ArrayList?).



More information about the Digitalmars-d-learn mailing list