# `setDiffSymmetric`

## Description

Returns the symmetric difference of two arrays, producing a new array with elements that exist in either `array1` or `array2` but not in both.

- Duplicates are discarded when computing the difference.
- Supported element types include `string`, `bool`, `number`, `interval`, `timestamp`, `regexp`, and `enum`.

## Syntax

Like many functions in DataPrime, `setDiffSymmetric` supports [two notations](https://coralogix.com/docs/dataprime/language-reference/functions-reference/index.md), **function** and **method** notation. These interchangeable forms allow flexibility in how you structure expressions.

```dataprime
setDiffSymmetric(array1: array<T>, array2: array<T>): array<T>
```

```dataprime
(array1: array<T>).setDiffSymmetric(array2: array<T>): array<T>
```

## Arguments

| Name   | Type  | Required | Description                 |
| ------ | ----- | -------- | --------------------------- |
| array1 | array | **true** | The first array to compare  |
| array2 | array | **true** | The second array to compare |

## Example

**Use case: Identify differences between two IP allow lists**

Suppose you maintain two separate allow lists of IP addresses. Consider the following input:

```json
{
    "ip_addresses_a": ["156.76.87.4", "156.76.12.4", "156.74.1.4"],
    "ip_addresses_b": ["156.76.87.4", "156.76.1.4"]
}
```

By applying `setDiffSymmetric`, you can find IPs that exist in one list but not the other.

### Example query

```dataprime
create diff_ips from setDiffSymmetric(ip_addresses_a, ip_addresses_b)
```

```dataprime
create diff_ips from ip_addresses_a.setDiffSymmetric(ip_addresses_b)
```

### Example output

The result will include a new field `diff_ips` showing only the differing elements:

```json
{
    "ip_addresses_a": ["156.76.87.4", "156.76.12.4", "156.74.1.4"],
    "ip_addresses_b": ["156.76.87.4", "156.76.1.4"],
    "diff_ips": ["156.76.12.4", "156.74.1.4", "156.76.1.4"]
}
```
