Success

data class Success<Error, Value>(data: Value) : Result<Error, Value>

A successful result of a computation.

See also

Parameters

data

the value returned by the computation.

Constructors

Success
Link copied to clipboard
fun <Value> Success(data: Value)
the value returned by the computation.

Functions

andThen
Link copied to clipboard
fun <T> andThen(chain: (Value) -> Result<Error, T>): Result<Error, T>
Chain two computations togetherIf in a computation chain the result of one computation is needed as input for another computation, andThen is there to chain the computations together.
andThenError
Link copied to clipboard
fun <T> andThenError(chain: (Error) -> Result<T, Value>): Result<T, Value>
Chain two computations together for error recovery.
component1
Link copied to clipboard
operator fun component1(): Value
copy
Link copied to clipboard
fun copy(data: Value): Success<Error, Value>
equals
Link copied to clipboard
open operator override fun equals(other: Any?): Boolean
hashCode
Link copied to clipboard
open override fun hashCode(): Int
map
Link copied to clipboard
fun <T> map(transform: (Value) -> T): Result<Error, T>
Transform a successful result.
mapError
Link copied to clipboard
fun <T> mapError(transform: (Error) -> T): Result<T, Value>
Transform a failed result.
orThrowException
Link copied to clipboard
fun orThrowException(exceptionProducer: (Error) -> Exception): Value
Unwrap the result by throwing an Exception that can depend on the kind of failureif a computation was a Success, return that data.
toString
Link copied to clipboard
open override fun toString(): String
use
Link copied to clipboard
fun use(actOn: (Value) -> Unit): Result<Error, Value>
Use the data of a successful result.
useError
Link copied to clipboard
fun useError(actOn: (Error) -> Unit): Result<Error, Value>
Use the error of a failed result.
withDefault
Link copied to clipboard
fun withDefault(defaultValue: Value): Value
Unwrap the result by providing a default value.
fun withDefault(producer: (Error) -> Value): Value
Unwrap the result by providing a default value that can depend on the kind of failure.

Properties

data
Link copied to clipboard
val data: Value
the value returned by the computation.