# `arrayJoin`

## Description

Returns a single string by joining the elements of an array using the specified delimiter.

- The element type must be compatible with string conversion.
- Supported element types include `string`, `bool`, `number`, `interval`, `timestamp`, `regexp`, and `enum`.

## Syntax

Like many functions in DataPrime, `arrayJoin` 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
arrayJoin(array: array<T>, delimiter: string): string
```

```dataprime
(array: array<T>).arrayJoin(delimiter: string): string
```

## Arguments

| Name      | Type   | Required | Description                                          |
| --------- | ------ | -------- | ---------------------------------------------------- |
| array     | array  | **true** | The array of values to join                          |
| delimiter | string | **true** | The string delimiter used to join the array elements |

## Example

**Use case: Build a readable message from array values**

Suppose you have a list of users who logged in. Consider the following input:

```json
{
    "users": ["Chip", "Ruby", "Glitch", "Cora"],
    "action": "LOGIN"
}
```

By joining the `users` array with a delimiter, you can generate a human-readable string that combines the array elements with other fields.

### Example query

```dataprime
create msg from `Users {arrayJoin(users, ',')} performed action {action}`
```

```dataprime
create msg from `Users {users.arrayJoin(',')} performed action {action}`
```

### Example output

The result will include a new field `msg` with the joined string:

```json
{
    "users": ["Chip", "Ruby", "Glitch", "Cora"],
    "action": "LOGIN",
    "msg": "Users Chip,Ruby,Glitch,Cora performed action LOGIN"
}
```
