Question:
I’ve looked at the source code of let function:example of code:
Answer:
this
in the let
lambda (block) means the same thing as it does outside the let
lambda. The let
lambda does not suddenly “change” what this
means.For example:
this
refers to the receiver of a function, but the function type of the parameter that let
takes has no receiver:run
, which is very similar to let
, except its receiver as the receiver of the block
parameter:this
and it
:usesBoth
with a lambda,this
in the lambda would refer to 1, because block
is called on x
in usesBoth
, and it
would refer to “x”, because y
is passed to block
as a parameter.If you have better answer, please add a comment about this, thank you!