let
Calls block with this value and returns its result.
The value is passed as an argument (it in an unnamed lambda), even when it is null. Use a safe call, value?.let { ... }, to skip the block for a null receiver. The block runs once; its exceptions propagate and it supports non-local returns.
val size = "hello".let { it.length }Content copied to clipboard
Receiver
value passed to the block.
Return
the value produced by block.
Parameters
block
transformation to run once.
Type Parameters
T
type of the receiver, which may be nullable.
R
type of the block result.