Table of Contents

Method ToEnumerable

Namespace
SodaFlow.Functional
Assembly
SodaFlow.Functional.dll

ToEnumerable<T>(Maybe<T>)

Views a Maybe<T> as a sequence of one element, or of no elements.

[Pure]
public static IEnumerable<T> ToEnumerable<T>(this Maybe<T> a)

Parameters

a Maybe<T>

The value to view as a sequence.

Returns

IEnumerable<T>

A sequence that holds only the contained value if there is one, and an empty sequence otherwise.

Type Parameters

T

The type of the value, when there is one.

Remarks

This is what lets code give a Maybe<T> to anything with a sequence parameter. That includes SelectMany, where it removes entries with no value in the same step that makes them.