A constructor member defined on a type.
A constructor plays the major role in initialization of an instance of a certain class. In source code, a programmer uses new
operator to invoke some constructor through dynamic binding, where engine will decide in runtime the appropriate constructor to call given the arguments passed along. In contrast, this class allows calling against an exact constructor.
Parent Class
Parent Interfaces
Type | Name | Signature |
---|---|---|
method | getAttributes | public Attribute[] getAttributes() |
method | getKind | public MemberKind getKind() |
method | getName | public String getName() |
method | getParameters | public Parameter[] getParameters() |
method | invoke | public Object invoke(Any[]) |
method | isStatic | public bool isStatic() |
method | toString | public String toString() |
public Attribute[] getAttributes()
(INHERITED DOC)
Get all the attributes annotated on the member definition.
The result array contains each instance of Attribute placed at the type definition.
Returns
public MemberKind getKind()
A constructor's kind is CONSTRUCTOR.
Returns
public String getName()
Get the name of this constructor, which is always the simple name of the class it belongs to.
Returns
public Parameter[] getParameters()
Get parameters of this constructor. The implicit 'this' argument is not included.
Returns
public Object invoke(var[] args)
Invoke this constructor to create a new object of the class to which the constructor belongs.
This is the programmatic way of class instantiation, which involves a series of steps similar to, but not entirely aligned with, the process initiated by new
operator. Upon calling this method, the script engine will (1) allocate memory on heap for this given class
(2) initialize each instance fields by default value or initializer expressions
(3) call exactly this constructor with the object itself represented by 'this' keyword. Forwarding calls to other constructors apply.
(4) return the object
Parameters
Returns
Throws
public bool isStatic()
A constructor is always false.
Returns
public String toString()
Get a string representation of this constructor member.
Returns
[CTOR|ctor-signature]
. ctor-signature
contains constructor name and each parameter's type. Example: [CTOR|MyClass(string)]