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

## [](#orelse1)orElse<T, E, R>(previous: Result<T, E>, 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"
}
```