for-in done the slow way: Get link Facebook X Pinterest Email Other Apps - June 03, 2013 for-in done the slow way:for Item in MyDictionary.Keys.ToArray do ... Get link Facebook X Pinterest Email Other Apps Comments Lars FosdalJune 4, 2013 at 12:18 AMA loop that modifies the list or array it is looping, is always tricky. Copying to an array can make sense - in spite of cost.ReplyDeleteRepliesReplyStefan GlienkeJune 4, 2013 at 12:23 AMLars 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).ReplyDeleteRepliesReplyAnthony FrazierJune 4, 2013 at 6:49 PMLars Fosdal True, but in many circumstances, there's probably better ways to make the desired changes.ReplyDeleteRepliesReplyAdd commentLoad more... Post a Comment
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.
ReplyDeleteLars 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).
ReplyDeleteLars Fosdal True, but in many circumstances, there's probably better ways to make the desired changes.
ReplyDelete