OptionExtensionsMapT1, T2, TOut(OptValueTupleT1, T2, FuncT1, T2, TOut) Method

Allows an option of a tuple (t1, t2) to map with a function taking two arguments t1 and t2.
C#
static int Add(int a, int b) => a + b;

var numbers = Some((1, 2));
var sum = numbers.Map(Add);
Assert(sum == Some(3));
This is mostly useful in enabling function composition.

Definition

Namespace: Orx.Fun.Option
Assembly: Orx.Fun.Option (in Orx.Fun.Option.dll) Version: 1.2.1+ea79806fa5e0e04bfdaef2a1916930e75e2cde74
C#
public static Opt<TOut> Map<T1, T2, TOut>(
	this Opt<(T1 , T2 )> option,
	Func<T1, T2, TOut> map
)

Parameters

option  OptValueTupleT1, T2
Option to be mapped.
map  FuncT1, T2, TOut
Map function.

Type Parameters

T1
Type of the first argument of the map function.
T2
Type of the second argument of the map function.
TOut
Type of return value of the map function.

Return Value

OptTOut

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type OptValueTupleT1, T2. 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