Deleting Arrays?

BlitzMax Forums/BlitzMax Beginners Area/Deleting Arrays?

blackwater(Posted 2011) [#1]
Searched for this but couldn't find anything, is there a way to delete or clear out an array and start over?


Jesse(Posted 2011) [#2]
array = new type[n]
or
array = Null


blackwater(Posted 2011) [#3]
That easy huh? Grrr, thanks!


blackwater(Posted 2011) [#4]
Follow up question, when I make the array equal null, it also wipes out the elements I predefined for it, in this case [500, 500]. How can I reassign the elements to it? I defined the array as a field in a type, which is why I need to clear it out from time to time.


Jesse(Posted 2011) [#5]
for an integer array:

array = new int[500,500]
this way you don'tt have to Null it. The dimensions must remain the same.

Last edited 2011


Czar Flavius(Posted 2011) [#6]
BlitzMax will automatically delete something when you no longer have any variables pointing to it. In the above examples, setting it to null will cause it to be deleted but that variable then no longer holds any array. Making it equal a new array does two things. A brand new array is created, and the variable points to it. The old variable no longer has anything pointing to it, and so is then collected.