Fold
Creates a new TState
value by applying the given folder
functions to state
and Either<TLeft, TRight>
value according to its state.
Parameters | Returns |
Func<TState, TRight, TState> folderWhenRight Func<TState, TLeft, TState> folderWhenLeft TState state Either<TLeft, TRight> either | TState |
Usage
This function applies the folder
function to the Either<TLeft, TRight>
value and to the state
according its state.
When Either IsRight
When Either IsLeft
One sided approach
You can also use the FoldLeft
and FoldRight
to produce the same results, but with these methods the folder is applied just to one of the possible values.
When the target type is different from Either
current value the result always will be equals to state
.
FoldRight when Either IsRight
FoldRight when Either IsLeft
FoldLeft Either IsRight
Last updated