> For the complete documentation index, see [llms.txt](https://www.selinux.tech/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://www.selinux.tech/scala/function-operation/f/filter.md).

# filter

## definition

```scala
    def filter(p: (A) ⇒ Boolean): Repr

    def filterNot(p: (A) ⇒ Boolean): Repr
```

## demo

```scala
val donuts: Seq[String] = Seq("Plain Donut", "Strawberry Donut", "Glazed Donut", "Vanilla Donut")

val sequenceWithPlainAndGlazedDonut = donuts.filter { donutName =>
  donutName.contains("Plain") || donutName.contains("Glazed")
}

val sequenceWithoutVanillaDonut = donuts.filterNot(_  == "Vanilla Donut" )
```
