toResult

inline fun <T> T?.toResult(): Result<Unit, T>

Turn a nullable type into a Result.

For a nullable type T?, toResult returns a Failure when the receiver is null and Success otherwise.

Return

the corresponding result for the receiver.

Parameters

<receiver>

an element of type T?.

T

the type of the receiver.