Skip to content
soliton4 edited this page Dec 7, 2014 · 1 revision

#unique - type modifier

Stability: 3 - Stable

requires

  • [dynamic type safety](dynamic type safety)

this modifier causes the first constructor parameter to be used as id.
there is also a implicit member "id" created.
there can only exist one instance per id.
if you create a second instance with the same id it will refer to the original instance.

  class type unique Singleton {
  };
  
  Singleton a = new Singleton("myid");
  Singleton b = new Singleton("myid"); // is the same object as a;
  Singleton c = new Singleton("otherid"); // a seperate instance;
  var id = c.id; // "otherid"

achievement

create singletons

continue reading about the savable modifier.

Clone this wiki locally