with

inline fun <T, R> with(receiver: T, block: T.() -> R): R(source)

Calls block with receiver as its receiver and returns its result.

Inside the block, this refers to receiver, including when that value is null. The block runs once; its exceptions propagate and it supports non-local returns.

Return

the value produced by block.

Parameters

receiver

value available as this in the block.

block

computation to run once.

Type Parameters

T

type of receiver, which may be nullable.

R

type of the block result.

See also