Interface IOptionMonad<T, TSelf>
Represents common interface for all option monads.
Inherited Members
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 Sourceoperator |(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 |
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. |
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. |
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 |
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. |
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 |