I am trying to run this example
fun main() {
val mlist: MutableList<String> = mutableListOf<String>()
val mapp: MutableMap<Int, MutableList<String>> = mutableMapOf(1 to mlist)
println(mapp)
mapp[1].add("a") // Correct is mapp[1]?.add("a")
println(mapp)
}
The compiler is complaining about Only safe (?.) or non-null asserted (!!.) calls are allowed on a nullable receiver of type MutableList<String>?.
Although I have defined MutableList<String> why the compiler says something about MutableList<String>?.
What does the compiler understand more than me?! What am I missing here?