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

# 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._
