Interface IOptionMonad<T>
Represents the common interface for all option monads.
Inherited Members
Namespace: DotNext
Assembly: DotNext.dll
Syntax
public interface IOptionMonad<T> : ISupplier<object?>, IFunctional<Func<object?>>
Type Parameters
| Name | Description |
|---|---|
| T | The type of the value in the container. |
Properties
| Edit this page View SourceHasValue
Indicates that this monad contains a value.
Declaration
bool HasValue { get; }
Property Value
| Type | Description |
|---|---|
| bool |
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
| Edit this page View SourceOr(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 |
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. |
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 |