This 表达式
- 在的成员中,this 指的是该类的当前对象。
- 在扩展函数或者中, this 表示在点左侧传递的 接收者 参数。
Implicit this
fun main() {
class A {
fun printLine() { println("Member function") }
fun invokePrintLine(omitThis: Boolean = false) {
}
}
A().invokePrintLine() // Member function
A().invokePrintLine(omitThis = true) // Top-level function