ResultExtensionsLinqMapUnwrapT Method

Unwraps all elements in the collection and returns Ok of the resulting list. If any of the elements is Err; then, the method returns the mapped error.
C#
var array = new Res<int>[3] { Ok(0), Ok(1), Ok(2) };
Res<List<int>> unwrapped = array.MapUnwrap();
Assert.True(unwrapped.IsOk);
Assert.Equal(new int[3] { 0, 1, 2 }, unwrapped.Unwrap());

var arrayWithErr = new Res<int>[3] { Ok(0), Err<int>("errmsg"), Ok(2) };
Res<List<int>> unwrappedWithErr = arrayWithErr.MapUnwrap();
Assert.True(unwrappedWithErr.IsErr);
Assert.Equal(Some("errmsg"), unwrappedWithErr.ErrorMessage());

Definition

Namespace: Orx.Fun.Result
Assembly: Orx.Fun.Result (in Orx.Fun.Result.dll) Version: 1.3.0+344c8bdd6f720ccfb2d8db7c61b76cf02be18f5f
C#
public static Res<List<T>> MapUnwrap<T>(
	this IEnumerable<Res<T>> collection
)

Parameters

collection  IEnumerableResT
Collection.

Type Parameters

T
Element type.

Return Value

ResListT

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type IEnumerableResT. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).

See Also