Workaround for container restrictions during iteration?

About Monkey 2 Forums Monkey 2 Programming Help Workaround for container restrictions during iteration?

Tagged: 

This topic contains 3 replies, has 2 voices, and was last updated by  MikeHart 2 years, 4 months ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #5441

    MikeHart
    Participant

    How do you get around the container restrictions that were introduced in M2, that you can’t dynamically add or remove items while you iterate through a container during an Eachin loop?

    Especially when you want to add to it. So far I have an idea where I store the new items in a second container which is then to be merged into the first one. Overkill I say.

    Does anyone know a reason why these restrictions where introduced? In MX it worked fine. When you want to remove something, make sure you iterate backwards. With adding it didn’t matter.

    #5443

    MikeHart
    Participant

    I have to add that only in debug mode you get these Concurrent list modification errors. In release mode it works fine.

    #5444

    Jesse
    Participant
    #5445

    MikeHart
    Participant

    Kinda, will have to adapt this to add items.

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.