U
User
I know you can't modify the objects of a collection when iterating
over them. So what's the standard practice for deleting all the items
in a collection? I've got a collection with a bunch of objects that
all have a function delete() that deletes the object and cleans up a
bunch of stuff. I want to delete all the objects in a collection:
for each x as ideletable in col
x.delete()
next
This of course doesn't work. Should I create and array, copy the
items into the array, and then iterate over the array and delete the
items?
dim ary(col.length) as ideletable
dim i as integer = 0
for each x as ideletable in col
ary(i) = x
i += 1
next
for i as integer = 0 to ary.length()
ctype(ary(i),ideletable).delete()
next
This methods works, but is the best way of doing this?
k.
over them. So what's the standard practice for deleting all the items
in a collection? I've got a collection with a bunch of objects that
all have a function delete() that deletes the object and cleans up a
bunch of stuff. I want to delete all the objects in a collection:
for each x as ideletable in col
x.delete()
next
This of course doesn't work. Should I create and array, copy the
items into the array, and then iterate over the array and delete the
items?
dim ary(col.length) as ideletable
dim i as integer = 0
for each x as ideletable in col
ary(i) = x
i += 1
next
for i as integer = 0 to ary.length()
ctype(ary(i),ideletable).delete()
next
This methods works, but is the best way of doing this?
k.