Table of Contents

Method SomeNotNull

Namespace
SodaFlow.Functional
Assembly
SodaFlow.Functional.dll

SomeNotNull<T>(T?)

Creates a Maybe<T> containing the given reference, unless it is null.

[Pure]
public static Maybe<T> SomeNotNull<T>(T? value) where T : class

Parameters

value T

The reference to contain if it is not null.

Returns

Maybe<T>

A Maybe<T> containing value if it is not null, and one containing no value otherwise.

Type Parameters

T

The type of the value, inferred from value.

Remarks

This is the bridge from the older convention, where a null reference stands for the absence of a value. It is deliberately not what Some<T>(T) does. That one holds null as it holds each other value. Thus, a Maybe<T> of a nullable type can tell no value at all from a value that is null.

SomeNotNull<T>(T?)

Creates a Maybe<T> containing the value of the given Nullable<T>, if it has one.

[Pure]
public static Maybe<T> SomeNotNull<T>(T? value) where T : struct

Parameters

value T?

The nullable value to change.

Returns

Maybe<T>

A Maybe<T> containing the value of value if it has one, and one containing no value otherwise.

Type Parameters

T

The underlying type of value.