fun main(arg: Array<String>) {

    val map = mutableMapOf("name" to "tom",
"age" to
)
val user = user(map)
println(user.name)
println(user.age)
user.name="cat"
println(map)
map.put("age",)
println(user.age)
} class user(var map:MutableMap<String,Any>){
var name:String by map
var age:Int by map
}
tom

{name=cat, age=}

MutableMap委托变化是双向的,是一种可读写委托

05-24 07:22