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

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