for-in done the slow way:

for-in done the slow way:

for Item in MyDictionary.Keys.ToArray do ...

Comments

  1. A loop that modifies the list or array it is looping, is always tricky.  Copying to an array can make sense - in spite of cost.

    ReplyDelete
  2. Lars Fosdal Which leads us to the flaw Generics.Collections have: no versioning and exception raising when modifying a collection that currently is being iterated (like .Net ones do - and Spring4d ones will after the refactoring).

    ReplyDelete
  3. Lars Fosdal True, but in many circumstances, there's probably better ways to make the desired changes.

    ReplyDelete

Post a Comment