ifPresentOrElse

fun ifPresentOrElse(action: (T) -> Unit, emptyAction: () -> Unit)

If a value is present, performs the given action with the value, otherwise performs the given empty-based action.

Parameters

action

the action to be performed if a value is present.

emptyAction

the action to be performed if no value is present.