whatIf

inline fun <T> T.whatIf(given: (T) -> Boolean?, whatIf: () -> Unit): T

An expression for invoking whatIf when the given boolean is true.

Return

Returns the original target object.

Parameters

given

A given condition for executing the whatIf lambda.

whatIf

An executable lambda function if the given condition pass.

inline fun <T> T.whatIf(given: (T) -> Boolean?, whatIf: () -> Unit, whatIfNot: () -> Unit): T

An expression for invoking whatIf when the given boolean is true. If the given boolean is false, whatIfNot will be invoked instead of the whatIf.

Return

Returns the original target object.

Parameters

given

A given condition for executing the whatIf or whatIfNot lambda.

whatIf

An executable lambda if the given condition pass.

whatIfNot

An executable lambda function if the given condition would not pass.

inline fun <T> T.whatIf(given: Boolean?, whatIf: T.() -> Unit): T

An expression for invoking whatIf when the given boolean is true. So it is useful when using with a chaining function like builder pattern or apply expression in kotlin.

Return

Returns the original target object.

Parameters

given

A given condition for executing the whatIf lambda.

whatIf

An executable lambda if the given condition pass.

inline fun <T> T.whatIf(given: Boolean?, whatIf: T.() -> Unit, whatIfNot: T.() -> Unit): T

An expression for invoking whatIf when the given boolean is true. If the given boolean is false, whatIfNot will be invoked instead of the whatIf. So it is useful when using with a chaining function like builder pattern or apply expression in kotlin.

Return

Returns the original target object.

Parameters

given

A given condition for executing the whatIf or whatIfNot lambda.

whatIf

An executable lambda if the given condition pass.

whatIfNot

An executable lambda function if the given condition would not pass.

inline fun <T> T.whatIf(given: () -> Boolean?, whatIfDo: T.() -> Unit): T

An expression for invoking whatIf when the given lambda's return value is true. So it is useful when using with a chaining function like builder pattern or apply expression in kotlin.

Return

Returns the original target object.

Parameters

given

A given condition for executing the whatIfDo lambda.

whatIfDo

An executable lambda if the given condition pass.

inline fun <T> T.whatIf(given: () -> Boolean?, whatIfDo: T.() -> Unit, whatIfNot: T.() -> Unit): T

An expression for invoking whatIf when the given lambda's return value is true. If the given boolean is false, whatIfNot will be invoked instead of the whatIfDo. So it is useful when using with a chaining function like builder pattern or apply expression in kotlin.

Return

Returns the original target object.

Parameters

given

A given condition for executing the whatIfDo or whatIfNot lambda.

whatIfDo

An executable lambda if the given condition pass.

whatIfNot

An executable lambda function if the given condition would not pass.

inline fun Boolean?.whatIf(whatIf: () -> Unit): Boolean?

An expression for invoking whatIf when the target Boolean is not null and true.

Return

Returns the desired type of object.

Parameters

whatIf

An executable lambda function if the Boolean is not null and true.

inline fun Boolean?.whatIf(whatIf: () -> Unit, whatIfNot: () -> Unit): Boolean?

An expression for invoking whatIf when the target object is not null and true. If the target is null or false, whatIfNot will be invoked instead of the whatIf.\

Return

Returns the desired type of object.

Parameters

whatIf

An executable lambda function if the Boolean is not null and true.

whatIfNot

An executable lambda function if the Boolean is null or false.