OptTDo Method

Runs action(Unwrap()) only if IsSome; and returns itself back.
C#
// the logging call will only be made if the result of GetOptionalUser is Some of a user.
// Since Do returns back the option, it can still be assigned to var 'user'.
Opt<User> user = GetOptionalUser().Do(u => Log.Info($"User '{u.Name}' grabbed"));

Definition

Namespace: Orx.Fun.Option
Assembly: Orx.Fun.Option (in Orx.Fun.Option.dll) Version: 1.2.1+ea79806fa5e0e04bfdaef2a1916930e75e2cde74
C#
public Opt<T> Do(
	Action<T> action
)

Parameters

action  ActionT
Action that will be called with the underlying value when Some.

Return Value

OptT

See Also