Re: AA.remove in foreach AA = new vs cleaning

2009-10-22 Thread Saaa
Saaa wrote: Steven Schveighoffer wrote But I've changed everything to `new` the array afterwards as I deleted all the keys anyways. Not sure what you mean here. foreach (K k, ; aa) { .. //aa.remove(k); } aa = new int[char]; Error: new can only create structs, dynamic arrays or

Re: AA.remove in foreach AA = new vs cleaning

2009-10-22 Thread Rainer Deyke
Saaa wrote: So, what is the fastest way to clean an AA? int[char] tmp; aa = tmp; -- Rainer Deyke - rain...@eldwood.com

Re: AA.remove in foreach AA = new vs cleaning

2009-10-21 Thread Steven Schveighoffer
On Wed, 21 Oct 2009 23:06:47 -0400, Saaa em...@needmail.com wrote: Is there anything with removing the current key in a foreach? foreach (K k, ; aa) { .. aa.remove(k); } Yes, behavior is undefined. from http://digitalmars.com/d/2.0/statement.html#ForeachStatement : The aggregate must

Re: AA.remove in foreach AA = new vs cleaning

2009-10-21 Thread Saaa
Steven Schveighoffer wrote: Yes, behavior is undefined. from http://digitalmars.com/d/2.0/statement.html#ForeachStatement : The aggregate must be loop invariant, meaning that elements to the aggregate cannot be added or removed from it in the [loop body] I suspect removing the current key

Re: AA.remove in foreach AA = new vs cleaning

2009-10-21 Thread Steven Schveighoffer
On Thu, 22 Oct 2009 00:45:36 -0400, Saaa em...@needmail.com wrote: Steven Schveighoffer wrote: Yes, behavior is undefined. from http://digitalmars.com/d/2.0/statement.html#ForeachStatement : The aggregate must be loop invariant, meaning that elements to the aggregate cannot be added or