Show / Hide Table of Contents

Interface IOptionMonad<T>

Represents the common interface for all option monads.

Inherited Members
ISupplier<object>.Invoke()
IFunctional.DynamicInvoke(scoped ref readonly Variant, int, scoped Variant)
IFunctional.GetArgument<T>(ref readonly Variant, int)
Namespace: DotNext
Assembly: DotNext.dll
Syntax
public interface IOptionMonad<T> : ISupplier<object?>, IFunctional
Type Parameters
Name Description
T

The type of the value in the container.

Properties

View Source

HasValue

Indicates that this monad contains a value.

Declaration
bool HasValue { get; }
Property Value
Type Description
bool
View Source

ValueOrDefault

If a value is present, returns the value, otherwise return default value.

Declaration
T? ValueOrDefault { get; }
Property Value
Type Description
T

The value stored in the container, if present, otherwise, default value.

Methods

View Source

Or(T?)

Returns the value if present; otherwise return default value.

Declaration
T? Or(T? defaultValue)
Parameters
Type Name Description
T defaultValue

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

Returns
Type Description
T

The value, if present, otherwise defaultValue.

View Source

OrInvoke(Func<T>)

Returns the value if present; otherwise invoke delegate.

Declaration
T OrInvoke(Func<T> defaultFunc)
Parameters
Type Name Description
Func<T> defaultFunc

A delegate to be invoked if value is not present.

Returns
Type Description
T

The value, if present, otherwise returned from delegate.

View Source

TryGet(out T)

Attempts to extract value from the container if it is present.

Declaration
bool TryGet(out T value)
Parameters
Type Name Description
T value

Extracted value.

Returns
Type Description
bool

true if value is present; otherwise, false.

Extension Methods

BasicExtensions.As<T>(T)
BasicExtensions.IsBetween<T, TLowerBound, TUpperBound>(T, TLowerBound, TUpperBound)
BasicExtensions.IsOneOf<T>(T, params ReadOnlySpan<T>)
  • View Source
☀
☾
In this article
Back to top
Supported by the .NET Foundation
☀
☾