> For the complete documentation index, see [llms.txt](https://gabriel-schade-cardoso.gitbook.io/tango/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://gabriel-schade-cardoso.gitbook.io/tango/modules/either/exists.md).

# Exists

Returns true if the given predicate functions return true when applied to either value. Otherwise, returns false.

| Parâmetros                                                                                                                   | Retorno |
| ---------------------------------------------------------------------------------------------------------------------------- | ------- |
| <p>Func\<TRight, bool> predicateWhenRight</p><p>Func\<TLeft, bool> predicateWhenLeft</p><p>Either\<TLeft, TRight> either</p> | bool    |

## Usage

When the `Either` `IsLeft`, the result will be the return of `predicateWhenLeft` function, otherwise will be the return of `predicateWhenRight`.

&#x20;**When Either IsRight and predicate returns true**&#x20;

```csharp
Either<string, int> either = 20;
bool result = 
    either.Exists(
        right => right == 20,
        left => left == "Hello World");

//result = true
```

&#x20;**When Either IsLeft and predicate returns true**&#x20;

```csharp
Either<string, int> either = "Hello World";
bool result = 
    either.Exists(
        right => right == 20,
        left => left == "Hello World");

//result = true
```

&#x20;**When Either IsRight and predicate returns false**

```csharp
Either<string, int> either = 15;
bool result = either.Exists(
right => right == 20,
left => left == "Hello World");
//result = false
```

&#x20;**One sided approach**

You can also use the `ExistsLeft` and `ExistsRight` to produce the same results, but with these methods the predicated is applied just to one of the possible values.

When the target type is different from `Either` current value the result always will be `false`

&#x20;**ExistsRight when Either IsRight**&#x20;

```csharp
Either<string, int> either = 20;
bool result = either.ExistsRight(right => right == 20);

//result = true
```

&#x20;**ExistsLeft when Either IsRight**&#x20;

```csharp
Either<string, int> either = 20;
bool result = either.ExistsLeft(left => left == "Hello World");

//result = false
```
