inspect method

Option<T> inspect(
  1. void action(
    1. T value
    )
)

Calls action with a present value, and returns this option unchanged.

final id = const Some<int>(7).inspect(print); // prints 7, returns Some(7)

Implementation

Option<T> inspect(void Function(T value) action) {
  if (this case Some<T>(:final value)) {
    action(value);
  }
  return this;
}