isOkAnd method

  1. @override
bool isOkAnd(
  1. bool f(
    1. T value
    )
)
override

Returns true if the result is Ok and the value matches the predicate f

Examples

Result<int, String> x = Ok(9);
expect(x.isOkAnd((int val) => val > 5), true);

expect(x.isOkAnd((int val) => val < 5), false);

Result<int, String> y = Err('An unexpected error occured');
expect(x.isOkAnd((_) => true), false);

Implementation

@override
bool isOkAnd(bool Function(T value) f) {
  return f(v);
}