inspectOk method
Executes a side effect if this is a success, then returns this unchanged.
The block callback is invoked with the success value if this is Ok.
The result is returned unchanged, allowing for method chaining. Useful
for logging, validation, or side effects without transforming the value.
Does nothing if this is Err.
Example:
result
.inspectOk((value) => logger.info('Success: $value'))
.inspectOk((value) => metrics.recordSuccess(value))
.andThen((v) => nextOperation(v));
Implementation
Result<T, E> inspectOk(void Function(T value) block) {
if (this case Ok(:final value)) {
block(value);
}
return this;
}