with
函数调用。
示例:
class MyClass {
fun f(): String = ""
}
fun testRedundant() {
with(c) { // <== 'with' is redundant since 'c' isn't used
println("1")
}
}
fun testOk() {
val c = MyClass()
with(c) { // <== OK because 'f()' is effectively 'c.f()'
println(f())
}
}