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

# contains

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

## Edition 0.1

```una
pub contains[T](xs: List[T], item: T) -> Bool
```

Compares structurally; in edition 0.2 and later, over any type with `Eq` (`spec/14 §1`, `spec/20 §6`).

## Edition 0.2 and later

```una
pub contains[T: Eq](xs: List[T], item: T) -> Bool
```

Compares structurally; in edition 0.2 and later, over any type with `Eq` (`spec/14 §1`, `spec/20 §6`).

In editions 0.2, 0.3, 0.4, 0.5. In edition 0.1: `contains[T](xs: List[T], item: T) -> Bool`\: no `Eq` constraint on `T`.

## Parameters

- `xs`: the list
- `item`: the value to look for

## Returns

`Bool`: `true` when an element of `xs` equals `item`\, compared structurally.

## Use instead

- [`first_where`](https://una-lang.org/en/docs/std/prelude/first_where/) to find the element itself\, by a condition

## Example

`src/shop.una`

```una
module shop

--- Whether a cart holds an item.
pub main() -> Unit
  uses @console: Console[print]
=
  let cart = ["lamp", "desk"]
  let desk = cart.contains(item: "desk")
  @console.print("desk: {desk}")
  let chair = cart.contains(item: "chair")
  @console.print("chair: {chair}")
```

`una run .` prints:

```text
desk: true
chair: false
```

## Specification

- [`spec/14 §1`](https://una-lang.org/en/docs/spec/14-standard-library/#s1)
- [`spec/20 §6`](https://una-lang.org/en/docs/spec/20-constraints-on-generics/#s6)

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