withDefault

fun withDefault(defaultValue: Value): Value

Unwrap the result by providing a default value.

If a computation was a Success, return that data. Otherwise return the provided default value.

Return

The data of a Success, defaultValue otherwise.

Parameters

defaultValue

The value in case of a Failure.

fun withDefault(producer: (Error) -> Value): Value

Unwrap the result by providing a default value that can depend on the kind of failure.

if a computation was a Success, return that data. Otherwise calculate a default value, depending on the failure.

Return

The data of a Success. The application of producer to the failure otherwise.

Parameters

producer

Provides the default value in case of a Failure.