map

inline fun <R> map(transform: (T) -> R): BleResult<R>

Transforms the success value using the given transform function.

If this is a Success, returns a new Success with the transformed value. If this is a Failure, returns the same Failure unchanged.

val stringResult: BleResult<String> = byteArrayResult
.map { bytes -> String(bytes, Charsets.UTF_8) }

Return

A new BleResult with the transformed value, or the original failure.

Parameters

transform

The function to apply to the success value.