Orhan Tozan
05/19/2020, 4:17 PMfun <T, R> Result<T>.letIfSuccess(
block: (data: T) -> Result<R>
): Result<R> = when (this) {
is Result.Failure -> this
is Result.Success -> block(this.data)
}
letIfSuccess returns Result<R>
, but returns Result<T>
when first branch of when statement is met.
I would expect it to give it a compile error, as Result<T> !is Result<R>
.Ruckus
05/19/2020, 4:50 PMResult.Failure
is Result<Nothing>
, whick is always satisfied.Orhan Tozan
05/19/2020, 4:55 PM