when<T, R> function

Maybe<R> when <T, R>(
  1. Maybe<T> self,
  2. {R some(
    1. T val
    ),
  3. R none(
      )}
    )

    Pattern matching

    if some and none all null Return None

    else when it has return Some(some(it)) or not has return Some(none(it))

    Implementation

    Maybe<R> when<T, R>(Maybe<T> self, {R some(T val), R none()}) {
      if (self is Some) {
        if (some != null) return Some(some(self.val));
      } else {
        if (none != null) return Some(none());
      }
      return None();
    }