Result<T> constructor

Result<T>(
  1. T computation(
      )
    )

    Creates a Result with the result of calling computation.

    This generates either a ValueResult with the value returned by calling computation, or an ErrorResult with an error thrown by the call.

    Implementation

    factory Result(T Function() computation) {
      try {
        return ValueResult<T>(computation());
      } on Object catch (e, s) {
        return ErrorResult(e, s);
      }
    }