---
schema_version: "1"
id: a88dc564fb7e7447fe9037eb7a73b891e0f1ad38d4fe3072b93878c3cd84cbca
title: partition
collection: mulesoft
version: current
locale: ja-jp
portal_url: https://docs.salesforce.com/mulesoft/current/ja-jp/dataweave/2.4/dw-arrays-functions-partition.md
canonical_url: https://docs.mulesoft.com/jp/dataweave/2.4/dw-arrays-functions-partition
source_site: docs.mulesoft.com
content_type: documentation
content_hash: 9a9e4011877d1477e948ba4085f0ea870362a8610b335590448a877eaf7ae52c
description: MuleSoft Documentation Site
release: "2.4"
latest: false
---
# partition

## [](#partition1)partition<T>(array: Array<T>, condition: (item: T) -> Boolean): { success: Array<T>, failure: Array<T> }

条件を満たす要素と条件を満たさない要素に配列を分割します。

_DataWeave バージョン 2.2.0 で導入されました。_​

### [](#パラメーター)パラメーター

<table class="tableblock frame-all grid-all stretch">
<colgroup>
<col style="width: 25%;">
<col style="width: 75%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">名前</th>
<th class="tableblock halign-left valign-top">説明</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">​<code>array</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">分割する要素の配列。</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">​<code>condition</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">配列の要素の照合に使用される条件 (式)。</p></td>
</tr>
</tbody>
</table>

### [](#例)例

次の例では、入力配列内で見つかった数字を分割します。偶数は、ラムダ式 ​`(item) → isEven(item)`​ で設定された条件に一致します。奇数は一致しません。関数の出力オブジェクト内では ​`"success"`​ キーと ​`"failure"`​ キーが生成されます。

#### [](#ソース)ソース

```DataWeave
%dw 2.0
import * from dw::core::Arrays
output application/json
var arr = [0,1,2,3,4,5]
---
arr partition (item) -> isEven(item)
```

#### [](#出力)出力

```json
{
  "success": [
    0,
    2,
    4
  ],
  "failure": [
    1,
    3,
    5
  ]
}
```

## [](#partition2)partition(array: Null, condition: (item: Nothing) -> Any): Null

`partition`​ を ​`null`​ 値に使用できるようにするヘルパー関数。

_DataWeave バージョン 2.4.0 で導入されました。_​