applyIf

inline fun <T> T.applyIf(predicate: Boolean, body: T.() -> T): T(source)

Conditionally applies the provided block to the receiver object if the predicate is true and returns the modified object.

Return

The modified receiver object if the predicate is true, or the original receiver object otherwise.

Parameters

predicate

The predicate to determine whether to apply the block.

body

The block of code to apply to the receiver object.