Scope functions execute some lambda expression in the context of some object.
There are several scope functions in Kotlin; perhaps the most popular one is
let()
.
Whatever you call let()
on becomes available in the lambda expression as it
.
Primarily, this is used in conjunction with a safe call (?.
), as shown here,
to conditionally execute that lambda expression if the value is not null
.
You can learn more about this in:
Tags: