Skip to content

Commit

Permalink
Merge pull request #143 from Kevin-Lee/docs/either-note
Browse files Browse the repository at this point in the history
Update: docs - either.md: NOTE
  • Loading branch information
kevin-lee committed Dec 29, 2021
2 parents 2cc81c0 + 2c812ce commit dc4509a
Showing 1 changed file with 31 additions and 1 deletion.
32 changes: 31 additions & 1 deletion website/docs/types/either.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ When your function (or method) is a partial function meaning that it may not hav

To make it a total function so that it always has the output for the given input, there can be multiple ways but an easy and recommended way is using `Either`.

:::caution NOTE
`Either` is right-biased meaning that the most well-known combinators on `Either` (e.g. `map`, `flatMap`, etc.) are by default for the `Right` value. If you want to manipulate the left one, you need to use the combinators for `Left` which are usually prefixed with `left` (e.g. `leftMap`, `leftFlatMap`, etc.).
:::

## Create

### Either.right to contain the result
Expand All @@ -29,7 +33,33 @@ Either.<String, Integer>left("Error message");
// Either<String, Integer> = Either.Right(1)
```

### Either Example
### `Either` from `Optional`

### `Either` from `Maybe`


## Transform
### `Either.map`

### `Either.flatMap`

### `Either.swap`



## Get the Value

### `Either.fold`


## Check Value in Either

### `Either.isRight`

### `Either.isLeft`


### Example
```java
import j8plus.types.Either;

Expand Down

0 comments on commit dc4509a

Please sign in to comment.