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

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

`previous`​ の try 結果が失敗の場合は ​`orElse`​ の結果を返し、失敗でない場合は ​`previous`​ の結果を返します。

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

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

<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">前の try 結果</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">前の try が失敗した場合に試行する次のオプション</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"
}
```