klyn.Type.getConstructor
method
public getConstructor(arity as Int = 0) as Constructor:
Description

Returns constructor metadata invocable with the requested arity.

A constructor whose trailing parameters have default values is considered invocable with fewer arguments. For example, a constructor declared as User(name as String = "guest") is returned by getConstructor() and by getConstructor(1).

Parameters
ParameterDescription
arityNumber of arguments that will be supplied.
Returns

Reflected constructor matching that arity.

Throws
  • TypeError if no constructor accepts that arity.
Example
ctor = User.type.getConstructor()
user = ctor.invoke() as User