Struct Maybe<T>
Represents a value that might be 'empty' or a valid value.
Implements
Inherited Members
Namespace: MaybeSharp
Assembly: cs.temp.dll.dll
Syntax
public struct Maybe<T> : IEquatable<Maybe<T>>, IEquatable<T>, IFormattable, IComparable, IComparable<Maybe<T>>, IComparable<T>
Type Parameters
Name | Description |
---|---|
T |
Constructors
Name | Description |
---|---|
Maybe(T) | Creates an instance that represents the specified value. |
Fields
Name | Description |
---|---|
Nothing | Represents an empty version of this maybe. |
Properties
Name | Description |
---|---|
HasValue | Returns true if this instance contains a valid, non-empty value. |
IsEmpty | Returns true if this instance is empty. |
Value | If HasValue is true, returns the value contained by this instance, otherwise throws a |
Methods
Name | Description |
---|---|
As<TResult>() | If this maybe is empty, returns an empty Maybe{TResult}. If this maybe is not empty, use the as keyword to convert it's value to TResult and returns a new maybe containing the result. |
Bind(Func<T, Maybe<T>>) | If this maybe is not empty, calls the specified function providing the value of this maybe and returns the result. If this maybe is nothing, returns an empty maybe. |
Bind<TResult>(Func<T, Maybe<TResult>>) | If this maybe is not empty, calls the specified function providing the value of this maybe and returns the result. If this maybe is nothing, returns an empty maybe. |
Cast<TResult>() | If this maybe is empty, returns an empty Maybe{TResult}. If this maybe is not empty, casts it's value to TResult and returns a new maybe containing the result. If the cast fails, an empty Maybe{TResult} is returned. |
CompareTo(T) | Compares this instance to a value of {T}. |
CompareTo(Maybe<T>) | Compares this instance to another instance of Maybe{T}. |
CompareTo(Object) | Compares this instance to the value specified. |
Equals(T) | Performs an equality check. |
Equals(Maybe<T>) | Performs an equality check. |
Equals(Object) | Performs an equality check. |
GetHashCode() | Returns the hashcode for this instance. |
ToString() | Returns the string <nothing> if IsEmpty is true, otherwise returns the result of the ToString method of the inner Value. |
ToString(String, IFormatProvider) | Formats the value of the current instance using the specified format. |
Operators
Name | Description |
---|---|
Equality(Maybe<T>, Maybe<T>) | Performs equality checking on Maybe{T} instances. |
Explicit(Maybe<T> to T) | Explicitly converts a Maybe{T} to it's {T} value if it is non-empty, otherwise throws an |
GreaterThan(Maybe<T>, T) | Returns true if |
GreaterThan(Maybe<T>, Maybe<T>) | Returns true if |
GreaterThanOrEqual(Maybe<T>, T) | Returns true if |
GreaterThanOrEqual(Maybe<T>, Maybe<T>) | Returns true if |
Implicit(T to Maybe<T>) | Allows implicit conversion from {T} to a Maybe{T} instance. |
Inequality(Maybe<T>, Maybe<T>) | Performs inequality checking on Maybe{T} instances. |
LessThan(Maybe<T>, T) | Returns true if |
LessThan(Maybe<T>, Maybe<T>) | Returns true if |
LessThanOrEqual(Maybe<T>, T) | Returns true if |
LessThanOrEqual(Maybe<T>, Maybe<T>) | Returns true if |