Method IfPresent
- Namespace
- DSharpPlus.Entities
- Assembly
- DSharpPlus.dll
IfPresent<TTarget>(Func<T, TTarget>)
Performs a mapping operation on the current Optional<T>, turning it into an Optional holding a
TTarget instance if the source optional contains a value; otherwise, returns an
Optional<T> of that same type with no value.
public Optional<TTarget> IfPresent<TTarget>(Func<T, TTarget> mapper)
Parameters
mapperFunc<T, TTarget>The mapping function to apply on the current value if it exists
Returns
- Optional<TTarget>
An Optional<T> containing a value denoted by calling
mapperif the current Optional<T> contains a value; otherwise, an empty Optional<T> of the target type.
Type Parameters
TTargetThe type of the target value returned by
mapper