---
schema_version: "1"
id: 1a7f983d9bdf9bbaca11ebf61d6c9c82fe31623d16b29649914f43230c8147e8
title: splitWhere
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/dataweave/latest/dw-arrays-functions-splitwhere.md
canonical_url: https://docs.mulesoft.com/dataweave/latest/dw-arrays-functions-splitwhere
source_site: docs.mulesoft.com
content_type: documentation
content_hash: 9fe3c0d8f632b9e75f982fc50f7e5595bccf48671664d256b0469404410bf7e3
description: MuleSoft Documentation Site
release: "2.13"
latest: true
---
---
product: DataWeave
version: 2.13
is-latest-version: true
---

# splitWhere

> For the full documentation index, see: https://docs.mulesoft.com/llms.txt

## splitWhere<T>(array: Array<T>, condition: (item: T) -> Boolean): Pair<Array<T>, Array<T>>

Splits an array into two at the first position where the condition is met.

_Introduced in DataWeave version 2.2.0._

### Parameters

<table><colgroup><col> <col></colgroup><thead><tr><th>Name</th><th>Description</th></tr></thead><tbody><tr><td><p><code>array</code></p></td><td><p>The array of elements to split.</p></td></tr><tr><td><p><code>condition</code></p></td><td><p>The condition (or expression) used to match an element in the array.</p></td></tr></tbody></table>

### Example

#### Source

```DataWeave
%dw 2.0
import * from dw::core::Arrays
output application/json
var users = ["Mariano", "Leandro", "Julian", "Tomo"]
---
users splitWhere (item) -> item startsWith "Jul"
```

#### Output

```json
{
  "l": ["Mariano", "Leandro"],
  "r": ["Julian", "Tomo"]
}
```

## splitWhere(array: Null, condition: (item: Nothing) -> Any): Null

Helper function that enables `splitWhere` to work with a `null` value.

_Introduced in DataWeave version 2.4.0._
