Used on its own, the
constructor keyword calls a different constructor on the same type:
type MyClass = public class public constructor; constructor(aName: String); property Name: String; end; constructor MyClass; begin constructor('My Name'); // calls the second constructor. end; constructor(aName: String); begin Name := aName; end;
Please refer to the Constructors: Deferred Construction topic for more details.
Constructor calls accept parameters, and they can also work with named and multi-part constructors. Just as in
new Expressions, the keyword can be followed (optionally) by a name, and/or a set of parameters. Unlike
new Expressions, constructor calls can not take additional properties to initialize, but that can be done as separate statements after the constructor call.
'inherited` Constructor Calls
constructor; begin DoSomeWork(); inherited constructor("Hello"); DoSomeMoreWork(); end;
'mapped` Constructor Calls
constructor; begin mapped constructor("Hello"); DoSomeAdditionalSetup(); end;
Please refer to the Mapped Types: Constructors sub-topic for more details.