tap<A> function

Option<A> Function(Option<A> option) tap<A>(
  1. void f(
    1. A value
    )
)

Execute a side effect on the wrapped value, if the Option is a Some.

expect(
  O.some(1).chain(O.tap(print)), // Prints '1' to the console
  equals(O.some(1)),
);

Implementation

Option<A> Function(Option<A> option) tap<A>(
  void Function(A value) f,
) =>
    map((a) {
      f(a);
      return a;
    });