Success

data class Success<out V>(val value: V) : Either<V, Nothing>

Successful result with value value.

Parameters

V

Type of the value.

Constructors

Link copied to clipboard
constructor(value: V)

Properties

Link copied to clipboard

True if the result is an error, false otherwise.

Link copied to clipboard

True if the result was successful, false otherwise.

Link copied to clipboard
val value: V

Functions

Link copied to clipboard
open override fun error(): Nothing?

Returns the error associated. In case of Success, error will be null.

Link copied to clipboard
fun <V, U, E : Throwable> Either<V, E>.flatMap(f: (V) -> Either<U, E>): Either<U, E>

Converts the Either value according to f function.

Link copied to clipboard
fun <V, E : Throwable, X : Throwable> Either<V, E>.flatMapError(f: (E) -> Either<V, X>): Either<V, X>

Converts the Either error according to f function.

Link copied to clipboard
fun <V, U, E : Throwable> Either<V, E>.map(f: (V) -> U): Either<U, E>

Converts the Either value according to f function.

Link copied to clipboard
fun <V, E : Throwable, X : Throwable> Either<V, E>.mapError(f: (E) -> X): Either<V, X>

Converts the Either error according to f function.

Link copied to clipboard
fun <V, E : Throwable> Either<V, E>.onFailure(f: (E) -> Unit)

Calls the function f with a specific error when Either is failure.

Link copied to clipboard
fun <V, E : Throwable> Either<V, E>.onSuccess(f: (V) -> Unit)

Calls the function f with a specific value when Either is successful.

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

Returns the value associated. In case of Failure, value will be null.