map

inline fun <T, R> DataResult<T>.map(transform: (T) -> R): DataResult<R>

Transforms the value inside DataResult.Success, leaving DataResult.Failure unchanged.

Allows for clean and safe operation on the result without throwing exceptions. Example: result.map { it.toString() } converts Success to Success.

Return

New DataResult with transformed value or original Failure.

Parameters

T

Original value type.

R

Value type after transformation.

transform

Function transforming value of type T to type R.