测试下with函数:
Kotlin
class Person {
var name: String = ""
var age: Int = 0
}
private fun testWith() {
val info = with(Person()) { //with函数 上下文引用:this(可省略);返回代码块最后一行结果;
name = "刘华强"
age = 30
"$name: 宋大哥,你混的早,孝敬你的人也多。"
}
println("zxzx, $info")
}
调用testwith函数,打印:

ok.