Home > Software engineering >  Unable to initialize kotlin class member from secondary function
Unable to initialize kotlin class member from secondary function

Time:10-03

class Person constructor(val first_name: String){
    init{
        println("Welcome, ${first_name}")
    }
    val last_name: String
    constructor(fname: String, lname: String): this(fname){
        this.last_name = lname
    }
    fun fullNameGreeting(){
        println("Welcome, ${first_name} ${last_name}")
    }
}

fun main() {
   val kotlin = "           
  • Related