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

# is_ok

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

```una
pub is_ok[T, E](r: Result[T, E]) -> Bool
  ensures result == (r is Ok)
```

Whether `r` is `Ok` (`spec/14 §1`).

## Parameters

- `r`: the result

## Returns

`Bool`: `true` exactly when `r` is `Ok`.

## See also

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

## Example

`src/shop.una`

```una
module shop

--- Whether a quantity was accepted.
checked_quantity(units: Int) -> Result[Int, Text] = if units > 0 then Ok(units) else Err("no units")

pub main() -> Unit
  uses @console: Console[print]
=
  let accepted = checked_quantity(0).is_ok()
  @console.print("accepted: {accepted}")
```

`una run .` prints:

```text
accepted: false
```

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