inspect method
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
@override
Result<T, E> inspect(void Function(T value) f) {
f(v);
return this;
}