---
schema_version: "1"
id: e6f62e28422f275b53047992c01e11d382abaac4d924c848036bee8ff0aeca5a
title: orElse
collection: mulesoft
version: current
locale: ja-jp
portal_url: https://docs.salesforce.com/mulesoft/current/ja-jp/dataweave/2.6/dw-runtime-functions-orelse.md
canonical_url: https://docs.mulesoft.com/jp/dataweave/2.6/dw-runtime-functions-orelse
source_site: docs.mulesoft.com
content_type: documentation
content_hash: 54f36dec6ccb284ad8c0d6b4ea7090b144929aac4a86daeb461440112855b871
description: MuleSoft Documentation Site
release: "2.6"
latest: false
---
# orElse

## [](#orelse1)orElse<T, R>(previous: TryResult<T>, orElse: () -> R): T | R

`try`​ に対する ​`previous`​ 引数が失敗する場合、​`orElse`​ 引数の結果を返します。それ以外の場合、この関数では ​`previous`​ 引数の値を返します。

_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>previous</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>try</code>​ に対する前のコールの結果。</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>orElse</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>previous</code>​ 引数が失敗する場合に返す引数。</p></td>
</tr>
</tbody>
</table>

### [](#例)例

次の例は、異なる try をチェーニングする方法を示しています。

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

```DataWeave
%dw 2.0
import * from dw::Runtime
var user = {}
var otherUser = {name: "DW"}
output application/json
---
{
    a: try(() -> user.name!) orElse "No User Name",
    b: try(() -> otherUser.name) orElse "No User Name"
}
```

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

```JSON
{
  "a": "No User Name",
  "b": "DW"
}
```