Struct Option<T>
Allows tracking of whether a value has be initialized (even with the default value) for both
reference and value types.
Useful where distinguishing between null (or zero, or false) and uninitialized is significant.
Assembly: Akka.dll
Syntax
public readonly struct Option<T>
Type Parameters
Constructors
|
Improve this Doc
View Source
Option(T)
Declaration
[Obsolete("Use Option<T>.Create() instead")]
public Option(T value)
Parameters
Type |
Name |
Description |
T |
value |
|
Fields
|
Improve this Doc
View Source
None
Declaration
public static readonly Option<T> None
Field Value
Properties
|
Improve this Doc
View Source
HasValue
Declaration
public readonly bool HasValue { get; }
Property Value
|
Improve this Doc
View Source
IsEmpty
Declaration
public readonly bool IsEmpty { get; }
Property Value
|
Improve this Doc
View Source
Value
Declaration
public readonly T Value { get; }
Property Value
Methods
|
Improve this Doc
View Source
Create(T)
Declaration
public static Option<T> Create(T value)
Parameters
Type |
Name |
Description |
T |
value |
|
Returns
|
Improve this Doc
View Source
Equals(Option<T>)
Declaration
public readonly bool Equals(Option<T> other)
Parameters
Type |
Name |
Description |
Option<T> |
other |
|
Returns
|
Improve this Doc
View Source
Equals(Object)
Declaration
public override readonly bool Equals(object obj)
Parameters
Type |
Name |
Description |
Object |
obj |
|
Returns
Overrides
|
Improve this Doc
View Source
FlatSelect<TNew>(Func<T, Option<TNew>>)
Unwraps the option value and returns it without converting it into an option.
Declaration
public readonly Option<TNew> FlatSelect<TNew>(Func<T, Option<TNew>> mapper)
Parameters
Type |
Name |
Description |
Func<T, Option<TNew>> |
mapper |
The mapping method.
|
Returns
Type Parameters
Name |
Description |
TNew |
The output type.
|
|
Improve this Doc
View Source
GetHashCode()
Declaration
public override readonly int GetHashCode()
Returns
Overrides
|
Improve this Doc
View Source
GetOrElse(T)
Gets option value, if any, otherwise returns default value provided
Declaration
public readonly T GetOrElse(T fallbackValue)
Parameters
Type |
Name |
Description |
T |
fallbackValue |
|
Returns
|
Improve this Doc
View Source
OnSuccess(Action<T>)
Applies specified action to this option, if there is a value
Declaration
public readonly void OnSuccess(Action<T> action)
Parameters
Type |
Name |
Description |
Action<T> |
action |
|
|
Improve this Doc
View Source
Select<TNew>(Func<T, TNew>)
Applies selector to option value, if value is set
Declaration
public readonly Option<TNew> Select<TNew>(Func<T, TNew> selector)
Parameters
Type |
Name |
Description |
Func<T, TNew> |
selector |
|
Returns
Type Parameters
|
Improve this Doc
View Source
ToString()
Declaration
public override readonly string ToString()
Returns
Overrides
Operators
|
Improve this Doc
View Source
Equality(Option<T>, Option<T>)
Declaration
public static bool operator ==(Option<T> left, Option<T> right)
Parameters
Returns
|
Improve this Doc
View Source
Implicit(T to Option<T>)
Performs an implicit conversion from T
to Option<T>.
Declaration
public static implicit operator Option<T>(T value)
Parameters
Type |
Name |
Description |
T |
value |
The object to convert
|
Returns
Type |
Description |
Option<T> |
The result of the conversion.
|
|
Improve this Doc
View Source
Inequality(Option<T>, Option<T>)
Declaration
public static bool operator !=(Option<T> left, Option<T> right)
Parameters
Returns
Extension Methods