# Computation Expression

### Option Computation Expression

Namespace: `FsToolkit.ErrorHandling`

### Examples:

#### Example 1

```fsharp
// int option
let addResult = option {
  let! x = tryParseInt "35"
  let! y = tryParseInt "5"
  let! z = tryParseInt "2"
  return add x y z
}
```

#### Example 2

Example taken from [here](https://github.com/lukaszkrzywizna/learn-fsharp/blob/feature/9-finito/LearnFsharp/Lesson.fs#L436-L456)

```fsharp
// int -> int -> int option
let tryDivide x y =
    match y with
    | 0 -> None
    | _ -> Some (x / y)

// int -> int -> int option
let multiplyIfEven x y =
    match y % 2 with
    | 0 -> Some <| x * y
    | _ -> None
 
// int option  
let resultNone = option {        
    let! result = tryDivide 5 3
    let mapped = result * 5
    return! multiplyIfEven 5 mapped
}
// result: None

// int option  
let resultSome = option {        
    let! result = tryDivide 6 3
    let mapped = result * 5
    return! multiplyIfEven 5 mapped
}
// result: Some 50

```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://demystifyfp.gitbook.io/fstoolkit-errorhandling/fstoolkit.errorhandling/option/ce.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
