transform<S> method

Optional<S> transform <S>(S transformer(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>(S transformer(T value)) {
  return _value == null
      ? new Optional.absent()
      : new Optional.of(transformer(_value));
}