transform<S extends Object> method

Optional<S> transform<S extends Object>(
  1. S transformer(
    1. T value
    )
)

Transforms the Optional value.

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

The transformer must not return null. If it does, an ArgumentError is thrown.

Implementation

Optional<S> transform<S extends Object>(S transformer(T value)) {
  return _value == null
      ? Optional<S>.absent()
      : Optional<S>.of(transformer(_value!));
}