Table of Contents

Delegate TryGet<T, TResult>

Namespace
SodaFlow.Functional
Assembly
SodaFlow.Functional.dll

A method that gives a value from one input if it can. It reports the result through its return value, and gives the value through an output parameter.

public delegate bool TryGet<in T, TResult>(T value, out TResult result)

Parameters

value T

The input to give a value from.

result TResult

Set to the value produced when this returns true, and left at the default for its type otherwise.

Returns

bool

true for a value, and false for none.

Type Parameters

T

The type of the input.

TResult

The type of the value produced.

Extension Methods

Remarks

TryParse(string, out int) and TryGetValue(TKey, out TValue) have this shape. Give one to FromTryGet<T, TResult>(T, TryGet<T, TResult>) to get a Maybe<T> as a replacement for a flag and an output parameter.