flatMapThrowable<B> method

Option<B> flatMapThrowable<B>(
  1. B f(
    1. T t
    )
)

Return a new Option that calls Option.tryCatch with the given function f.

expect(
  Option.of(123).flatMapThrowable((_) => throw Exception()),
  Option.of(123).flatMapThrowable((_) => 456),
  Option.of(456),
);

Implementation

Option<B> flatMapThrowable<B>(B Function(T t) f) =>
    flatMap((t) => Option.tryCatch(() => f(t)));