> 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/option/foldback.md).

# FoldBack

Creates a new `TState` value by applying the given `folder` function to `state` and `Option<T>.Some` option value. Otherwise returns the `state` itself.

| Parameters                                                                        | Returns |
| --------------------------------------------------------------------------------- | ------- |
| <p>Func\<T, TState, TState> folder</p><p>Option\<T> option</p><p>TState state</p> | TState  |

## Usage

This function applies the `folder` function to the `Option<T>` value and to the `state`.

When the optional value `IsNone` the `folder` function won't be executed and the `state` is returned as a result.

This function is similar to `Fold`, the only difference between these two functions are the parameters order and the parameters order of the `folder` function.

&#x20;**When the option value IsSome**&#x20;

```csharp
int state = 30
Option<int> optionValue = 10;
int result = optionValue.FoldBack(
                (value, _state) => value + _state,
                state);

//result = 40
```
