Hi, I’m a rookie about kotlin, and I have a questi...
# getting-started
i
Hi, I’m a rookie about kotlin, and I have a question about null-safety. Here is an example:
Copy code
class People(n: String) {
    val name = n
}

class Test {
    var me: People? = null
    
    fun initial() {
    	me = People("Inaction")
	}
    
    fun hi(name: String) {
        println(name)
    }
    
    fun doSomething() {
        initial()
        me?.let {
            hi(me.name)
        }
    }
}

fun main(args: Array<String>) {
    Test().doSomething()
}
Check the codes in
doSomething
function, and I got the error:
Smart cast to 'People' is impossible, because 'me' is a mutable property that could have been changed by this time
So what should I do to solve this error?