Class MaybeChooseExtensions
- Namespace
- Trellis
- Assembly
- Trellis.Results.dll
Extension methods for filtering and unwrapping Maybe<T> collections.
public static class MaybeChooseExtensions
- Inheritance
-
MaybeChooseExtensions
- Inherited Members
Methods
Choose<T>(IEnumerable<Maybe<T>>)
Filters a sequence of Maybe<T> values and returns only the underlying values where HasValue is true.
public static IEnumerable<T> Choose<T>(this IEnumerable<Maybe<T>> source) where T : notnull
Parameters
sourceIEnumerable<Maybe<T>>The sequence of Maybe<T> values to filter.
Returns
- IEnumerable<T>
An IEnumerable<T> containing only the unwrapped values from items that have a value.
Type Parameters
TThe type of the value contained in the Maybe<T>.
Exceptions
- ArgumentNullException
Thrown when
sourceis null.
Choose<T, TResult>(IEnumerable<Maybe<T>>, Func<T, TResult>)
Filters a sequence of Maybe<T> values, unwraps them, and transforms the values using the specified selector function.
public static IEnumerable<TResult> Choose<T, TResult>(this IEnumerable<Maybe<T>> source, Func<T, TResult> selector) where T : notnull
Parameters
sourceIEnumerable<Maybe<T>>The sequence of Maybe<T> values to filter and transform.
selectorFunc<T, TResult>A transform function to apply to each unwrapped value.
Returns
- IEnumerable<TResult>
An IEnumerable<T> containing the transformed values from items that have a value.
Type Parameters
TThe type of the value contained in the Maybe<T>.
TResultThe type of the transformed result.
Exceptions
- ArgumentNullException
Thrown when
sourceorselectoris null.