---
schema_version: "1"
id: f057f49b47c438163aec2769ac8b7e4d7425e36c38a2ad6d7304eeaba0413f99
title: firstWith
collection: mulesoft
version: current
locale: ja-jp
portal_url: https://docs.salesforce.com/mulesoft/current/ja-jp/dataweave/2.3/dw-arrays-functions-firstwith.md
canonical_url: https://docs.mulesoft.com/jp/dataweave/2.3/dw-arrays-functions-firstwith
source_site: docs.mulesoft.com
content_type: documentation
content_hash: f1b6f81b8321025430838dc65bc8cea96adc9f144d08730405e74b628bd9e205
description: MuleSoft Documentation Site
release: "2.3"
latest: false
---
# firstWith

## [](#firstwith1)firstWith(Array<T>, (item: T, index: Number) -> Boolean): T | Null

条件を満たす最初の要素を返すか、条件を満たす要素がない場合は ​`null`​ を返します。

_DataWeave 2.3.0 で導入されました。Mule 4.3 以降でサポートされます。_​

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

<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">array (配列)</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">condition (条件)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">満たす条件。</p></td>
</tr>
</tbody>
</table>

### [](#例)例

次の例では、要素が一致する場合と要素が一致しない場合の ​`firstWith`​ の動作を示します。

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

```DataWeave
%dw 2.0
output application/json
import firstWith from dw::core::Arrays
var users = [{name: "Mariano", lastName: "Achaval"}, {name: "Ana", lastName: "Felisatti"}, {name: "Mariano", lastName: "de Sousa"}]
---
{
  a: users firstWith ((user, index) -> user.name == "Mariano"),
  b: users firstWith ((user, index) -> user.name == "Peter")
}
```

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

```Json
{
  "a": {
    "name": "Mariano",
    "lastName": "Achaval"
  },
  "b": null
}
```