List inside classMonkey Forums/Monkey Beginners/List inside class
| I remember doing this in another language (maybe C# or BMax), but I can't exactly remember which one of having a list inside a class definition that I could store all my instanced objects of that class.|
For example, if I have a coins class and I create a coin, I can keep that coin inside a list within the class definition,
Is this possible with Monkey, if ss whats the syntax for this?
| The class itself should contain a list with all created instances of itself?|
Class Coin Global all:List<Coin> = New List<Coin> Field value:Int Method New() value = 0 all.AddLast(Self) End Method New(value:Int) Self.value = value all.AddLast(Self) End End Function Main:Int() Local c1:= New Coin Local c2:= New Coin Local c3:= New Coin(10) Print Coin.all.Count Return 0 End