rhodonite
    Preparing search index...

    Class Ok<T, ErrObj>

    Represents a successful result containing a value. This class indicates that an operation completed successfully.

    Type Parameters

    • T

      The type of the success value

    • ErrObj

      The type of the error object (for type compatibility)

    Hierarchy

    Implements

    Index

    Constructors

    Properties

    val?: T | RnError<ErrObj>

    The value to store (either success value or error)

    Methods

    • Chains operations on this successful result. Applies the provided function to the contained value.

      Type Parameters

      • U

        The type of the new success value

      Parameters

      • f: (value: T) => Result<U, ErrObj>

        Function to apply to the success value

      Returns Result<U, ErrObj>

      The result of applying the function

    • Pattern matching implementation for Result types.

      Type Parameters

      • R

        The type of the return value from the Ok function

      • ErrObj2

        The type of the new error object

      Parameters

      Returns Result<R, ErrObj2>

      A new Result containing the result of the pattern matching

      If the result is neither Ok nor Err

    • Gets the name of this result class.

      Returns string

      The constructor name ('Ok' or 'Err')

    • Safely returns the contained value.

      Returns T

      The contained success value

    • Returns the contained value since this is a successful result. The compensation function is not called.

      Parameters

      Returns T

      The contained success value