whatIfMap

inline fun <T, R> T.whatIfMap(default: R, whatIf: (T) -> R): R

An expression for invoking whatIf when the T target object is not null. It is useful when the receiver T and the result R should be different.

Return

Returns the desired type of object.

Parameters

default

An executable default value if the T target object is not null.

whatIf

An executable lambda if the T target object is not null.

inline fun <T, R> T.whatIfMap(whatIf: (T) -> R, whatIfNot: (T) -> R): R

An expression for invoking whatIf when the T target object is not null. It is useful when the receiver T and the result R should be different.

Return

Returns the desired type of object.

Parameters

whatIf

An executable lambda if the T target object is not null.

whatIfNot

An executable lambda function if the T target object is null.

inline fun <T, R> T.whatIfMap(given: Boolean?, default: R, whatIf: (T) -> R): R

An expression for invoking whatIf when the given boolean value. If the given boolean value is false, the result value is the default. It is useful when the receiver T and the result R should be different.

Return

Returns the desired type of object.

Parameters

given

A given condition for executing the whatIf lambda.

default

An executable default value if the given condition would not pass.

whatIf

An executable lambda if the given condition pass.

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

An expression for invoking whatIf when the given boolean value. If the given boolean is false, whatIfNot will be invoked instead of the whatIf. It is useful when the receiver T and the result R should be different.

Return

Returns the desired type of object.

Parameters

given

A given condition for executing the whatIf lambda.

whatIf

An executable lambda if the given condition pass.

whatIfNot

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