> For the complete documentation index, see [llms.txt](https://osl.mistium.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://osl.mistium.com/standard-library/utilities/option.md).

# option

Use `option` to model a value that may be present (`some`) or absent (`none`) without relying on `null`.

`option` is a built-in language type. It needs no package import.

## Example

```osl
auto value = some(42)
log value.unwrapOr(0)
```

## API reference

### `option` values

| Method                   | Returns   | Notes                                                         |
| ------------------------ | --------- | ------------------------------------------------------------- |
| `value.isSome()`         | `boolean` |                                                               |
| `value.isNone()`         | `boolean` |                                                               |
| `value.unwrap()`         | `T`       | Returns the stored value, or fails for `none`.                |
| `value.unwrapOr(def: T)` | `T`       | Returns the contained value or a fallback.                    |
| `value.expect(msg: any)` | `T`       | Uses the same checked accessor with a custom failure message. |

## Behavior and limits

`some(null)` remains a present option; presence is not inferred from whether the stored value is null.
