tryMap<P> method

  1. @override
Maybe<P> tryMap<P>(
  1. P mapper(
    1. T value
    )
)
override

Tries to map value to P. If the mapper throws anything (not just an Exception), returns Nothing<P>.

Implementation

@override
Maybe<P> tryMap<P>(P Function(T value) mapper) {
  try {
    return Just(mapper(value));
  } catch (_) {
    return Nothing();
  }
}