I've looked at the source code of let function:
@kotlin.internal.InlineOnly
public inline fun <T, R> T.let(block: (T) -> R): R {
contract {
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
}
return block(this)
}
i clearly understand that using it keyword inside of the block (code) i'm sending to let function will refer to the object that called the let function. But on which object does this keyword will refer if i will use it inside the block (code). The way i see it, it should be the same object that it refer to, but i'm not sure. My computer gone bad so i can't test it by myself. Can someone not only give me the answer but also will explain me the logic behind the this keyword in the situation above?
example of code:
val p:Preson = Person()
p.let{**this**}