Your class can have more than one constructor, if desired. The primary constructor goes in the class declaration. Other constructors are called "secondary constructors" and appear as functions with the constructor name instead of a regular function name.

Secondary constructors can have bodies, rather than relying solely on the init block.

Also, secondary constructors must chain to the primary constructor. This is accomplished by a this() call, appearing after the secondary constructor's parameter list, separated by a :. The parameters passed to the this() call need to match the parameters required by the primary constructor.

You can learn more about this in:
Run Edit