List inside class

Monkey Forums/Monkey Beginners/List inside class

boomboom(Posted 2014) [#1]
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?

Danilo(Posted 2014) [#2]
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

    Method New(value:Int)
        Self.value = value

Function Main:Int()
    Local c1:= New Coin
    Local c2:= New Coin
    Local c3:= New Coin(10)
    Print Coin.all.Count
    Return 0