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

# or_else

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

```una
pub or_else[T](o: Option[T], default: T) -> T
```

The value `v` when `o` is `Some(v)`, and `default` when `o` is `None`; `default` is an argument like any other, evaluated before the call (`spec/14 §1`).

## Parameters

- `o`: the option
- `default`: the value for `None`\, evaluated before the call

## Returns

`T`: the value of `Some`\, and `default` for `None`.

## See also

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

## Example

`src/shop.una`

```una
module shop

--- The first item of a cart, or a placeholder.
pub main() -> Unit
  uses @console: Console[print]
=
  let empty: List[Text] = []
  let shown = empty.first().or_else(default: "nothing yet")
  @console.print(shown)
```

`una run .` prints:

```text
nothing yet
```

## 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).
