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

# ends_with

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

```una
pub ends_with(t: Text, suffix: Text) -> Bool
```

Whether `t` ends with `suffix` (`spec/22 §2`).

## Parameters

- `t`: the text
- `suffix`: the text `t` may end with

## Returns

`Bool`: `true` when the last scalar values of `t` are those of `suffix`.

## See also

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

## Cost

Time `O(m)` (ADR 0070), where:

- `m`: the length of `suffix` in UTF\-8 bytes

## Example

`src/shop.una`

```una
module shop

--- Whether an uploaded invoice is a PDF.
pub main() -> Unit
  uses @console: Console[print]
=
  let pdf = ends_with("invoice-2026.pdf", suffix: ".pdf")
  @console.print("invoice-2026.pdf: {pdf}")
  let text = ends_with("invoice-2026.txt", suffix: ".pdf")
  @console.print("invoice-2026.txt: {text}")
```

`una run .` prints:

```text
invoice-2026.pdf: true
invoice-2026.txt: false
```

## Specification

- [`spec/22 §2`](https://una-lang.org/en/docs/spec/22-text/#s2)

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