transformNullable<S> method

Optional<S> transformNullable<S>(
  1. S? transformer(
    1. T value
    )
)

Transforms the Optional value.

If the Optional is absent(), returns absent() without applying the transformer.

Returns absent() if the transformer returns null.

Implementation

Optional<S> transformNullable<S>(S? Function(T value) transformer) {
  return _value == null
      ? Optional<S>.absent()
      : Optional<S>.fromNullable(transformer(_value));
}