Constructor in Kotlin

ref – https://www.programiz.com/kotlin-programming/constructors

In Kotlin, a class can also contain one or more secondary constructors. They are created using constructor keyword.

The most common use of secondary constructor comes up when you need to extend a class that provides multiple constructors that initialize the class in different ways.

For example, you want to initialize your class with absolutely no parameters. And then other instances where you want to initialize it with multiple parameters.

In our Log example, we have two secondary constructors. No primary constructor.

Constructor calling constructor

In Kotlin, you can also call a constructor from another constructor of the same class using this().
In our case, say for a 1 parameter constructor, we call a 2 parameter constructor right after the one parameter constructor finishes running.