ItsA shame that I need to ask such basic quastions
Monkey Forums/Monkey Programming/ItsA shame that I need to ask such basic quastions
| ||
Since the Reference is soo bad I have to ask so many basic quastions but I have no choice........ How to delete a Class Object? what is the command or method? |
| ||
First, no need to be ashamed, we all have or had these kind of questions. ;) Second, you can't delete a class, only instances of a class. Third, you can't do it in Monkey, the garbage collector does it for you. You can set the instance variable to zero. That will force the garbage collector to clean it up. |
| ||
sorry, i ment instance, thats why i wrote a class Object. Thanks Xaron for the quick help now i have more 93% stuff left to learn :p |
| ||
You can set the instance variable to zero Isnt it null? ' WARNING: BAD EXAMPLE CODE! if not player.isAlive then player = null end |
| ||
Also, if you want to be sure something is gone, make sure all references to the object are nulled as well. |
| ||
Class instances are removed from memory when there are no variables pointing to them. That's how high level managed languages usually work.Local a:= New MyClass 'A is the only instance of this object Local b:MyClass = a 'Now there ire 2 variables pointing to the same object a = Null 'The object is not destroyed yet, as "b" is still poiting to it. b = Null 'The object is now ready to be destroyed automatically by the garbage collector |
| ||
therevills: Isnt it null? Methinks Xaron may be an old-school C coder... #define NULL 0 |