Adding to a type while processing....

Blitz3D Forums/Blitz3D Programming/Adding to a type while processing....

JBR(Posted 2008) [#1]
Hi, using For Each ... to go through and process a bunch of objects of the same type.

While doing this I'd like to add more objects of this type.

I don't care if the added objects are processed in this loop or not.

Is this ok to do or should I add the objects after my For Each loop?

Thanks
Jim


GfK(Posted 2008) [#2]
Not sure. There's two ways it could go.

Does the For/Each loop determine the start/end of the count at the start? Or does it keep going until there are no objects left?

In the first case, you should be OK as any objects added since the start won't be processed. On the other hand, you could find yourself stuck in an infinite loop.

Best way is to try it and see.


Stevie G(Posted 2008) [#3]
From memory, if you add to the type list within the loop the new instances will be referenced during the loop.