---
schema_version: "1"
id: 420e4ffd0327a96d74540c32d5d317a80186364382d3736bbda1486e326253cb
title: divideBy
collection: mulesoft
version: current
locale: ja-jp
portal_url: https://docs.salesforce.com/mulesoft/current/ja-jp/dataweave/2.6/dw-arrays-functions-divideby.md
canonical_url: https://docs.mulesoft.com/jp/dataweave/2.6/dw-arrays-functions-divideby
source_site: docs.mulesoft.com
content_type: documentation
content_hash: c395554030447176fa7ca886156a27685efcb5323c0572d6e0a0de7d7570515a
description: MuleSoft Documentation Site
release: "2.6"
latest: false
---
# divideBy

## [](#divideby1)divideBy<T>(items: Array<T>, amount: Number): Array<Array<T>>

配列を、指定数の要素が含まれるサブ配列に分割します。

入力配列内の要素数が指定数より少ない場合、 この関数は 1 つのサブ配列にそれらの要素を入力します。指定数より多い場合、 この関数は、必要な数のサブ配列に追加の 要素を入力します。

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

<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>items</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>amount</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">サブ配列あたりの許容される要素数。</p></td>
</tr>
</tbody>
</table>

### [](#例)例

次の例では、指定された ​`amount`​ (数量) に基づいて配列をサブ配列に分割します。

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

```DataWeave
%dw 2.0
import * from dw::core::Arrays
output application/json
---
{
  "divideBy" : [
      { "divideBy2" : [1, 2, 3, 4, 5] divideBy 2 },
      { "divideBy2" : [1, 2, 3, 4, 5, 6] divideBy 2 },
      { "divideBy3" : [1, 2, 3, 4, 5] divideBy 3 }
  ]
}
```

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

```JSON
{
 "divideBy": [
  {
    "divideBy2": [
      [ 1, 2 ],
      [ 3, 4 ],
      [ 5 ]
    ]
  },
  {
    "divideBy2": [
      [ 1, 2 ],
      [ 3, 4 ],
      [ 5, 6 ]
    ]
  },
    {
      "divideBy3": [
        [ 1, 2, 3 ],
        [ 4, 5 ]
      ]
    }
 ]
}
```

## [](#divideby2)divideBy(items: Null, amount: Any): Null

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

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