This Expression
- In a member of a class, this refers to the current object of that class.
- In an or a function literal with receiver this denotes the receiver parameter that is passed on the left-hand side of a dot.
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