Prev: FAQ 6.17 How do I efficiently match many regular expressions at once?
Next: FAQ 4.73 How do I keep persistent data across program calls?
From: Sherm Pendley on 28 Feb 2010 13:59 "A. Farber" <alexander.farber(a)gmail.com> writes: > From searching I know, that this is because > I'm removing an element of an array > whil iterating over it. > > But my question is, how could I workaround it? Instead of removing elements immediately, push them onto another array. Once you're done iterating over the "main" array, iterate over the "hit list" array and remove the elements in it from the "main" array. sherm--
From: A. Farber on 28 Feb 2010 14:04
On Feb 28, 7:59 pm, Sherm Pendley <sh...(a)debian.shermpendley.com> wrote: > "A. Farber" <alexander.far...(a)gmail.com> writes: > > From searching I know, that this is because > > I'm removing an element of an array > > whil iterating over it. > > Instead of removing elements immediately, push them > onto another array. Once you're done iterating over > the "main" array, iterate over the "hit list" array > and remove the elements in it from the "main" array. Good idea, thank you! |