getOrElse
Returns the encapsulated value if this instance represents Success or the result of onFailure function for the encapsulated Failure if it is failure.
This allows for a safe "exit" from the DataResult container by providing a fallback value or performing a non-local return (e.g., in a transaction block).
Examples:
val data = result.getOrElse { emptyList() }
//...
val value = result.getOrElse { return it } // Early return the failureContent copied to clipboard
Return
Parameters
Type Parameters
R
The result type.
T
The type of the value in Success.