# set.retain_all_copy · Rell standard library · Chromia Docs (concept)

> function retain_ all_ copy(values: collection <-T>): set <T> Returns a new set whose elements are those found in both this set and the given collection, or

Source: https://docs.chromia.com/pages/rell-stdlib/-rell-system-library/root/set/retain_all_copy/

FUNCTION

# set.retain\_all\_copy

```signature
function retain_all_copy(values: collection<-T>): set<T>
```

Returns a new set whose elements are those found in both this set and the given collection, or in
other words, the intersection of this set and the given collection.

**Parameters**

* **values** — the other collection

**Returns**

a new set whose elements are the intersection of this set and the given collection

`a.retain_all_copy(b)` is equivalent to `a & b`, where `a` and `b` are sets.

Examples:

* `set([1]).retain_all_copy(set([1]))` returns `set([1])`
* `set([1]).retain_all_copy(set([2]))` returns `set([])`
* `set([1, 2, 3]).retain_all_copy(set([2, 3, 4]))` returns `set([2, 3])`

Since 0.14.16

[View this page on docs.chromia.com](https://docs.chromia.com/pages/rell-stdlib/-rell%20-system%20-library/%5Broot%5D/set/retain_all_copy.html)Generated API reference, mirrored from the live docs
