Dela via


Optional.IfPresentOrElse(IConsumer, IRunnable) Method

Definition

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

[Android.Runtime.Register("ifPresentOrElse", "(Ljava/util/function/Consumer;Ljava/lang/Runnable;)V", "", ApiSince=33)]
public void IfPresentOrElse (Java.Util.Functions.IConsumer? action, Java.Lang.IRunnable? emptyAction);
[<Android.Runtime.Register("ifPresentOrElse", "(Ljava/util/function/Consumer;Ljava/lang/Runnable;)V", "", ApiSince=33)>]
member this.IfPresentOrElse : Java.Util.Functions.IConsumer * Java.Lang.IRunnable -> unit

Parameters

action
IConsumer

the action to be performed, if a value is present

emptyAction
IRunnable

the empty-based action to be performed, if no value is present

Attributes

Remarks

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

Added in 9.

Java documentation for java.util.Optional.ifPresentOrElse(java.util.function.Consumer<? super T>, java.lang.Runnable).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to