Table of Contents

Method ValueOrDefault

Namespace
SodaFlow.Functional
Assembly
SodaFlow.Functional.dll

ValueOrDefault<T>(Maybe<T>)

Returns the contained value if there is one, and the default for its type otherwise.

[Pure]
public static T? ValueOrDefault<T>(this Maybe<T> a)

Parameters

a Maybe<T>

The value to read.

Returns

T

The contained value, or default if there is none.

Type Parameters

T

The type of the value.

Remarks

This is the one helper here that cannot say which case you got. For a type whose default is itself a legitimate value, such as zero, false, or null, the answer is ambiguous. Use it only where that genuinely has no effect.