Err<T, E> constructor
const
Err<T, E> (
- E e
Result
is a type that that represents either success (Ok
) or failure (Err
)
Examples
Basic usage:
class FallibleOpSuccess {}
class FallibleOpFailure {}
Result<FallibleOpSuccess, FallibleOpFailure> fallibleOp() {
if (true) {
return Ok(FallibleOpSuccess());
} else {
return Err(FallibleOpFailure());
}
}
final result = fallibleOp();
result.inspect((value) {
print('Success with value: $value');
}).inspectErr((error) {
print('Failure with error: $error');
});
}
Implementation
const Err(this.e);