klyn.Type.getConstructor
method
public getConstructor(arity as Long = 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). Variadic constructors accept any argument count greater than or equal to their required fixed parameter count.

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