SumType<T1,T2,T3,T4>.Match<TResult> Method

Definition

Runs a delegate corresponding to which type is contained inside this instance.

public TResult Match<TResult> (Func<T1,TResult> firstMatch, Func<T2,TResult> secondMatch, Func<T3,TResult> thirdMatch, Func<T4,TResult> fourthMatch, Func<TResult> defaultMatch = default);
public TResult Match<TResult> (Func<T1,TResult> firstMatch, Func<T2,TResult> secondMatch, Func<T3,TResult> thirdMatch, Func<T4,TResult> fourthMatch, Func<TResult>? defaultMatch = default);
member this.Match : Func<'T1, 'Result> * Func<'T2, 'Result> * Func<'T3, 'Result> * Func<'T4, 'Result> * Func<'Result> -> 'Result
Public Function Match(Of TResult) (firstMatch As Func(Of T1, TResult), secondMatch As Func(Of T2, TResult), thirdMatch As Func(Of T3, TResult), fourthMatch As Func(Of T4, TResult), Optional defaultMatch As Func(Of TResult) = Nothing) As TResult

Type Parameters

TResult

The type that all the delegates will return.

Parameters

firstMatch
Func<T1,TResult>

Delegate to handle the case where this instance contains a T1.

secondMatch
Func<T2,TResult>

Delegate to handle the case where this instance contains a T2.

thirdMatch
Func<T3,TResult>

Delegate to handle the case where this instance contains a T3.

fourthMatch
Func<T4,TResult>

Delegate to handle the case where this instance contains a T4.

defaultMatch
Func<TResult>

Delegate to handle the case where this instance is uninhabited. If this delegate isn't provided the default TResult will be returned instead.

Returns

TResult

The TResult instance created by the delegate corresponding to the current type stored in this instance.

Applies to