Java – Kotlin initializes an object

Kotlin initializes an object… here is a solution to the problem.

Kotlin initializes an object

I

have a base class that is being extended, but I want to extend the View where the normal Java constructor is.

class TextView(context: Context?) : ViewAbstractClass(context) 

I’m not sure how to do this in Kotlin. What is the structure of Kotlin that allows you to do complex initialization of objects?

Solution

https://kotlinlang.org/docs/reference/classes.html#constructors

class Customer(name: String) {
    init {
        logger.info("Customer initialized with value ${name}")
    }
}

Related Problems and Solutions