ResultExtensions<T, E> extension

Extension methods for Result

on

Methods

bind<U>(Result<U, E> f(T)) Result<U, E>

Available on Result<T, E>, provided by the ResultExtensions extension

Performs a bind operation and returns a new instance with a new type. The 'bind' method allows chaining operations that may fail.
map<U>(U f(T)) Result<U, E>

Available on Result<T, E>, provided by the ResultExtensions extension

The 'map' method transforms the successful value without changing the error.
match<U>({required U onSuccess(T), required U onError(E)}) → U

Available on Result<T, E>, provided by the ResultExtensions extension

Achieves the same thing as a switch expression with pattern matching. You should consider using a switch expression, but sometimes the match function is simpler
merge<M, J>(Result<J, E> other, M onJoin(T, J)) Result<M, E>

Available on Result<T, E>, provided by the ResultExtensions extension

Performs a merge operation and returns a new instance of M.
resultOr(T or) → T

Available on Result<T, E>, provided by the ResultExtensions extension

Returns the result a the specified value

Operators

operator >>(Result<T, E> transform(T)) Result<T, E>

Available on Result<T, E>, provided by the ResultExtensions extension

Performs a bind operation and returns a new instance.
operator |(T or) → T

Available on Result<T, E>, provided by the ResultExtensions extension

Returns the success value if it exists, otherwise returns or