Search Results for

    Show / Hide Table of Contents

    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.

    Inherited Members
    object.Equals(object, object)
    object.GetType()
    object.ReferenceEquals(object, object)
    Namespace: Akka.Util
    Assembly: Akka.dll
    Syntax
    public readonly struct Option<T>
    Type Parameters
    Name Description
    T

    The type of the optional value.

    Constructors

    | Edit this page View Source

    Option(T)

    Declaration
    [Obsolete("Use Option<T>.Create() instead")]
    public Option(T value)
    Parameters
    Type Name Description
    T value

    Fields

    | Edit this page View Source

    None

    None.

    Declaration
    public static readonly Option<T> None
    Field Value
    Type Description
    Option<T>

    Properties

    | Edit this page View Source

    HasValue

    Gets a value indicating whether this option has a value.

    Declaration
    public bool HasValue { get; }
    Property Value
    Type Description
    bool
    | Edit this page View Source

    IsEmpty

    Declaration
    public bool IsEmpty { get; }
    Property Value
    Type Description
    bool
    | Edit this page View Source

    Value

    Gets the value contained in this option.

    Declaration
    public T Value { get; }
    Property Value
    Type Description
    T

    Methods

    | Edit this page View Source

    Create(T)

    Declaration
    public static Option<T> Create(T value)
    Parameters
    Type Name Description
    T value
    Returns
    Type Description
    Option<T>
    | Edit this page View Source

    Equals(Option<T>)

    Declaration
    public bool Equals(Option<T> other)
    Parameters
    Type Name Description
    Option<T> other
    Returns
    Type Description
    bool
    | Edit this page View Source

    Equals(object)

    Declaration
    public override bool Equals(object obj)
    Parameters
    Type Name Description
    object obj
    Returns
    Type Description
    bool
    Overrides
    ValueType.Equals(object)
    | Edit this page View Source

    FlatSelect<TNew>(Func<T, Option<TNew>>)

    Unwraps the option value and returns it without converting it into an option.

    Declaration
    public Option<TNew> FlatSelect<TNew>(Func<T, Option<TNew>> mapper)
    Parameters
    Type Name Description
    Func<T, Option<TNew>> mapper

    The mapping method.

    Returns
    Type Description
    Option<TNew>
    Type Parameters
    Name Description
    TNew

    The output type.

    | Edit this page View Source

    GetHashCode()

    Declaration
    public override int GetHashCode()
    Returns
    Type Description
    int
    Overrides
    ValueType.GetHashCode()
    | Edit this page View Source

    GetOrElse(T)

    Gets option value, if any, otherwise returns default value provided

    Declaration
    public T GetOrElse(T fallbackValue)
    Parameters
    Type Name Description
    T fallbackValue
    Returns
    Type Description
    T
    | Edit this page View Source

    OnSuccess(Action<T>)

    Applies specified action to this option, if there is a value

    Declaration
    public void OnSuccess(Action<T> action)
    Parameters
    Type Name Description
    Action<T> action
    | Edit this page View Source

    Select<TNew>(Func<T, TNew>)

    Applies selector to option value, if value is set

    Declaration
    public Option<TNew> Select<TNew>(Func<T, TNew> selector)
    Parameters
    Type Name Description
    Func<T, TNew> selector
    Returns
    Type Description
    Option<TNew>
    Type Parameters
    Name Description
    TNew
    | Edit this page View Source

    ToString()

    Declaration
    public override string ToString()
    Returns
    Type Description
    string
    Overrides
    ValueType.ToString()

    Operators

    | Edit this page View Source

    operator ==(Option<T>, Option<T>)

    Declaration
    public static bool operator ==(Option<T> left, Option<T> right)
    Parameters
    Type Name Description
    Option<T> left
    Option<T> right
    Returns
    Type Description
    bool
    | Edit this page View Source

    implicit operator Option<T>(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.

    | Edit this page View Source

    operator !=(Option<T>, Option<T>)

    Declaration
    public static bool operator !=(Option<T> left, Option<T> right)
    Parameters
    Type Name Description
    Option<T> left
    Option<T> right
    Returns
    Type Description
    bool

    Extension Methods

    ObjectExtensions.IsDefaultForType<T>(T)
    ObjectExtensions.AsOption<T>(T)
    Extensions.AsInstanceOf<T>(object)
    In this article
    • githubEdit this page
    • View Source
    Back to top
    Contribute
    • Project Chat
    • Discussion Forum
    • Source Code
    Support
    • Akka.NET Support Plans
    • Akka.NET Observability Tools
    • Akka.NET Training & Consulting
    Maintained By
    • Petabridge - The Akka.NET Company
    • Learn Akka.NET