Success

Represents a successful operation that resulted in a returned SuccessType.

Functions

Link copied to clipboard
open override fun failure(): Nothing

Returns a failure value if the result is Failure.

Link copied to clipboard
open override fun isFailure(): Boolean

Returns true if Result finished with failure.

Link copied to clipboard
open override fun isSuccess(): Boolean

Returns true if Result finished successfully.

Link copied to clipboard
open override fun value(): SuccessType

Returns a value if the result is Success.

Inherited functions

Link copied to clipboard
inline fun <V, F, V2, F2> Result<V, F>.bimap(successMapper: (V) -> V2, failureMapper: (F) -> F2): Result<V2, F2>

Maps success value or failure.

Link copied to clipboard
inline fun <V, F, V2> Result<V, F>.flatMap(mapper: (V) -> Result<V2, F>): Result<V2, F>

Maps success value to a new Result or passes failure.

Link copied to clipboard
inline fun <V, F, R> Result<V, F>.fold(ifSuccess: (V) -> R, ifFailure: (F) -> R): R

Folds success or failure into a final value.

Link copied to clipboard
inline fun <V, F> Result<V, F>.ifFailure(ifFailure: (F) -> Unit): Result<V, F>

Performs provided operation if Result is failure.

Link copied to clipboard
inline fun <V, F> Result<V, F>.ifSuccess(ifSuccess: (V) -> Unit): Result<V, F>

Performs provided operation if Result is success.

Link copied to clipboard
inline fun <V, F, V2> Result<V, F>.map(mapper: (V) -> V2): Result<V2, F>

Maps success value or passes failure.

Link copied to clipboard
inline fun <V, F, F2> Result<V, F>.mapFailure(mapper: (F) -> F2): Result<V, F2>

Maps failure or passes success value.

Link copied to clipboard
fun <L, R> Result<R, L>.toEither(): Either<L, R>

Converts Result to Either. Result.Failure will be converted to Either.Left and Result.Success will be converted to Either.Right.

Link copied to clipboard
inline fun <V, F> Result<V, F>.valueOr(handler: (F) -> V): V

Returns success value or uses handler to map failure to value.