also

inline fun <T> T.also(block: (T) -> Unit): T(source)

Calls block with this value and returns this value.

Use this function for an additional action, such as logging. The value is passed as an argument (it in an unnamed lambda), even when it is null; the block result is discarded. The block runs once; its exceptions propagate and it supports non-local returns.

Receiver

value passed to the block and returned.

Return

the original receiver, without copying it.

Parameters

block

action to run once.

Type Parameters

T

type of the receiver, which may be nullable.

See also