---
title: "Option"
url: https://una-lang.org/en/docs/std/prelude/Option/
release: v0.4.0
edition: "0.1 and later"
source: https://github.com/una-lang/una/blob/v0.4.0/docs/std/listing.json
---

# Option

A kind of the prelude, in scope in every module. Edition 0.1 and later.

```una
pub kind Option[T] = Some(value: T) | None
```

Either `Some(value)`, which holds one value of `T`, or `None`, which holds none (`spec/14 §1`).

## Variants

- `Some(value)`: a value is there; `value` is the value
- `None`: no value is there

## See also

[`is_some`](https://una-lang.org/en/docs/std/prelude/is_some/), [`or_else`](https://una-lang.org/en/docs/std/prelude/or_else/)

## Example

`src/shop.una`

```una
module shop

--- A discount code, if the customer typed one.
code_of(typed: Text) -> Option[Text] = if typed.len > 0 then Some(typed) else None

describe(typed: Text) -> Text
=
  when code_of(typed)
    is Some(code) -> "code {code}"
    is None -> "no code"

pub main() -> Unit
  uses @console: Console[print]
=
  @console.print(describe("SPRING"))
  @console.print(describe(""))
```

`una run .` prints:

```text
code SPRING
no code
```

## Specification

- [`spec/14 §1`](https://una-lang.org/en/docs/spec/14-standard-library/#s1)

Generated from the standard modules of una v0.4.0 ([`docs/std/listing.json`](https://github.com/una-lang/una/blob/5fec93d88932b333feec25e589355a2cb34c37b5/docs/std/listing.json), which is not part of the specification). The specification governs: [`spec/14 §1`](https://una-lang.org/en/docs/spec/14-standard-library/#s1).
