inspect abstract method

Result<T, E> inspect(
  1. void f(
    1. T value
    )
)

Calls the provided closure with the contained value (if Ok)

Examples

Result<int, String> parseToInt(String value) {
  try {
    return Ok(int.parse(value));
  } catch (_) {
    return Err(value);
  }
}

Result<int, String> x = parseToInt('4')
  .inspect((val) => print('original: $val')) // prints 'original: 4'
  .map((val) => val * val);

Implementation

Result<T, E> inspect(void Function(T value) f);