Result

public enum Result<A, B>

A result captures both successful and failed return values of a method.

  • Create a successful result with the provided value.

    Declaration

    Swift

    public init(success a: A)

    Parameters

    a

    successful value represented by this result.

  • Create a failed result with the provided value.

    Declaration

    Swift

    public init(failure b: B)

    Parameters

    b

    failure value represented by this result.

  • Determine whether two results containing equatable values are equal.

    Declaration

    Swift

    public static func==(lhs: Result, rhs: Result) -> Bool

    Parameters

    lhs

    left-hand result to compare.

    rhs

    right-hand result to compare.

    Return Value

    true if lhs are both successes or failures containing equal values.

  • Infix version of bind returning a value rather than a function.

    See more

    Declaration

    Swift

    public static func >>>=<C>(_ result: Result, _ f: @autoclosure @escaping () -> (A) -> Result<C, B>) -> Result<C, B>

    Parameters

    result

    incoming Result to evaluate.

    f

    function mapping a value to a Result.

    Return Value

    the result of f if result was successful, result otherwise.