alsoIf

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

Conditionally applies the provided transformation function to the receiver object if the predicate is true and returns the result. If the predicate is false, the receiver object itself is returned.

Return

The result of the transformation function if the predicate is true, or the receiver object itself otherwise.

Parameters

predicate

The predicate to determine whether to apply the transformation function.

body

The transformation function to apply to the receiver object.