Best way to remove a reference to an array?

Monkey Forums/Monkey Programming/Best way to remove a reference to an array?

custardsquare(Posted 2011) [#1]
Hi there
I'm currently working on a Monkey port of an actionscript 3 game. In AS3, to remove a reference to an array you set the reference to null. In monkey code, this throws an error. I thought about array.Resize(0) but apparently this will return a new array.
Is there something I'm missing or is there no way to remove a reference to an array without creating a new array?

cheers,

Ethan


JaviCervera(Posted 2011) [#2]
The best solution is probably array = array.Resize(0)


FlameDuck(Posted 2011) [#3]
I'm not sure what you're trying to do here. What is the use case? When would you remove a reference to an Array which doesn't happen because: a) the Array is no longer in the program scope or b) The Array needs to be replaced by another Array?


Beaker(Posted 2011) [#4]
To add to what FlameDuck/Jedive said: if you have a large array just shrink it using array.Resize(0), or let it go out of scope (or both).


Skn3(Posted 2011) [#5]
It would be good if monkey could translate array = null to array.resize(0). Purely for a standard way of nulling objects/data.... Or at least sone way to remove an array without having to test Length() to see if the array is dead.


custardsquare(Posted 2011) [#6]
Thanks for your replies everyone. I guess working in mobile with AS3 has made me too cautious about memory usage. The array at this point should be outside the program scope and should be garbage collected. I guess I'll find out.