applyIf

inline fun <T : Any> T.applyIf(shouldApplyBlock: (T) -> Boolean, block: T.() -> Unit): T

Calls the specified function block with this value as its receiver if and only if the shouldApplyBlock lambda returns true. Returns this value.


inline fun <T : Any> T.applyIf(shouldApply: Boolean, block: T.() -> Unit): T

Calls the specified function block with this value as its receiver if and only if the shouldApply parameter is true. Returns this value.

Sources

Link copied to clipboard
Link copied to clipboard