and<U> method

  1. @override
  2. @useResult
Result<U, E> and<U>(
  1. Result<U, E> other
)
override

Returns other if this is an Ok, or an Err of the original error otherwise.

Examples

// prints "Ok(3)"
print(const Ok<int, String>(2).and(const Ok(3)));

// prints "Err(error)"
print(const Err<int, String>('error').and(const Ok(3)));

Implementation

@override
@useResult
Result<U, E> and<U>(Result<U, E> other) => other;