Result

value class Result<out T> : Serializable

A Result type that holds either a value of type T or an error message String.

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
Link copied to clipboard

Functions

Link copied to clipboard
Link copied to clipboard
inline fun <R> flatMap(transform: (T) -> Result<R>): Result<R>
Link copied to clipboard
inline fun <R> fold(onSuccess: (T) -> R, onFailure: (String) -> R): R
Link copied to clipboard
inline fun getOrElse(onFailure: (String) -> T): T
Link copied to clipboard
fun getOrNull(): T?
Link copied to clipboard
fun getOrThrow(): T

Returns the encapsulated value if this instance represents success or throws IllegalStateException with the failure message if it is failure.

Link copied to clipboard
inline fun <R> map(transform: (T) -> R): Result<R>
Link copied to clipboard
inline fun onFailure(action: (String) -> Unit): Result<T>
Link copied to clipboard
inline fun onSuccess(action: (T) -> Unit): Result<T>
Link copied to clipboard
inline fun recover(transform: (String) -> T): Result<T>