map<R> method

Result<R> map<R>(
  1. R transform(
    1. T value
    )
)

Maps the value of Result if it is Success or returns the same Result otherwise.

Implementation

Result<R> map<R>(R Function(T value) transform) {
  return switch (this) {
    Success(value: final value) => Result.success(transform(value)),
    Failure(error: final error) => Result.failure(error),
  };
}