Show / Hide Table of Contents

Interface IOptionMonad<T, TSelf>

Represents common interface for all option monads.

Inherited Members
IOptionMonad<T>.HasValue
IOptionMonad<T>.ValueOrDefault
IOptionMonad<T>.Or(T)
IOptionMonad<T>.OrInvoke(Func<T>)
IOptionMonad<T>.TryGet(out T)
ISupplier<object>.Invoke()
ISupplier<object>.NullOrDefault
IFunctional<Func<object>>.ToDelegate()
Namespace: DotNext
Assembly: DotNext.dll
Syntax
public interface IOptionMonad<T, TSelf> : IOptionMonad<T>, ISupplier<object?>, IFunctional<Func<object?>> where TSelf : struct, IOptionMonad<T, TSelf>
Type Parameters
Name Description
T

The type of the value in the container.

TSelf

The implementing type.

Operators

| Edit this page View Source

operator |(in TSelf, T?)

Returns the value if present; otherwise return default value.

Declaration
public static T? operator |(in TSelf container, T? defaultValue)
Parameters
Type Name Description
TSelf container

The container to check.

T defaultValue

The value to be returned if there is no value present.

Returns
Type Description
T

The value, if present, otherwise defaultValue.

| Edit this page View Source

operator |(in TSelf, in TSelf)

Returns non-empty container.

Declaration
public static TSelf operator |(in TSelf x, in TSelf y)
Parameters
Type Name Description
TSelf x

The first container.

TSelf y

The second container.

Returns
Type Description
TSelf

The first non-empty container.

| Edit this page View Source

explicit operator T(in TSelf)

Attempts to extract the value from the container.

Declaration
public static abstract explicit operator T(in TSelf container)
Parameters
Type Name Description
TSelf container

The container.

Returns
Type Description
T

The extracted value.

| Edit this page View Source

operator false(in TSelf)

Checks whether the container has no value.

Declaration
public static bool operator false(in TSelf container)
Parameters
Type Name Description
TSelf container

The container to check.

Returns
Type Description
bool

true if this container has no value; otherwise, false.

| Edit this page View Source

implicit operator TSelf(T)

Places the value to the container.

Declaration
public static abstract implicit operator TSelf(T value)
Parameters
Type Name Description
T value

The value to be placed into the container.

Returns
Type Description
TSelf

The constructed monad.

| Edit this page View Source

operator true(in TSelf)

Checks whether the container has value.

Declaration
public static bool operator true(in TSelf container)
Parameters
Type Name Description
TSelf container

The container to check.

Returns
Type Description
bool

true if this container has value; otherwise, false.

  • Edit this page
  • View Source
☀
☾
In this article
Back to top
Supported by the .NET Foundation
☀
☾