exists method

bool exists(
  1. bool predicate(
    1. R value
    )
)

Returns false if Left or returns the result of the application of the given predicate to the Right value.

Example

Right<int, int>(12).exists((v) => v > 10); // Result: true
Right<int, int>(7).exists((v) => v > 10);  // Result: false

Left<int, int>(12).exists((v) => v > 10);  // Result: false
Left<int, int>(12).exists((v) => v < 10);  // Result: false

Implementation

bool exists(bool Function(R value) predicate) => _foldInternal(
      ifLeft: _const(false),
      ifRight: predicate,
    );