applyIf

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

Applies the given block if the if value is true, only return the object itself if not.

Return

This instance.

Parameters

if

Whether the block should be applied.

block

The block to be applied.


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

Applies the given block if the ifPredicate results to true, only return the object itself if not.

Return

This instance.

Parameters

ifPredicate

Results to whether the block should be applied.

block

The block to be applied.

Sources

Link copied to clipboard
Link copied to clipboard