OptionExtensionsFlattenT Method

Flattens the option of option of T. Maps Opt<Opt<T>> to Opt<T> as follows:
  • None => None<T>(),
  • Some(None<T>()) => None<T>(),
  • Some(Some(T)) => Some(T).
C#
Assert(None<Opt<char>>().Flatten() == None<char>());
Assert(Some(None<char>()).Flatten() == None<char>());
Assert(Some(Some('c')).Flatten() == Some('c'));

Definition

Namespace: Orx.Fun.Option
Assembly: Orx.Fun.Option (in Orx.Fun.Option.dll) Version: 1.2.1+ea79806fa5e0e04bfdaef2a1916930e75e2cde74
C#
public static Opt<T> Flatten<T>(
	this Opt<Opt<T>> option
)

Parameters

option  OptOptT
Nested option to flatten.

Type Parameters

T

[Missing <typeparam name="T"/> documentation for "M:Orx.Fun.Option.OptionExtensions.Flatten``1(Orx.Fun.Option.Opt{Orx.Fun.Option.Opt{``0}})"]

Return Value

OptT

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type OptOptT. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).

See Also