Skip to content

Commit

Permalink
Merge pull request #163 from Kevin-Lee/docs/either-isRight
Browse files Browse the repository at this point in the history
Update: docs - `either.md`: add `isRight`
  • Loading branch information
kevin-lee committed Dec 30, 2021
2 parents f5a3a46 + 462cec2 commit 8496d90
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions website/docs/types/either.md
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,25 @@ errorMsgOrMillis.fold(err -> Instant.now(), millis -> Instant.ofEpochMilli(milli

## Check Value in Either

If you want to chekc if `Either` is `Right` or `Left`, you can use `isRight()` and `isLeft()` respectively.

### `Either.isRight`
To check if the `Either` is `Right`, use `isRight()`,
```java
import j8plus.types.Either;

final Either<String, Integer> errorMsgOrNum = Either.right(999);
// Either<String, Integer> = Right(999)

errorMsgOrNum.isRight();
// boolean = true

final Either<String, Integer> errorMsgOrNum2 = Either.left("Error message");
// Either<String, Integer> = Left(Error message)

errorMsgOrNum2.isRight();
// boolean = false
```

### `Either.isLeft`

Expand Down

0 comments on commit 8496d90

Please sign in to comment.