Skip to content

Commit db07747

Browse files
committed
Syntax lookup: if / else
1 parent 61b1cf9 commit db07747

File tree

2 files changed

+37
-20
lines changed

2 files changed

+37
-20
lines changed

misc_docs/syntax/controlflow_ifelse.mdx

Lines changed: 0 additions & 20 deletions
This file was deleted.

misc_docs/syntax/language_if_else.mdx

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
---
2+
id: "if-else"
3+
keywords: ["if", "else"]
4+
name: "if / else"
5+
summary: "This is the `if / else` control flow."
6+
category: "languageconstructs"
7+
---
8+
9+
Use `if / else` expressions to express a value through a `true` / `false` condition.
10+
11+
### Example
12+
13+
<CodeTab labels={["ReScript", "JS Output"]}>
14+
15+
```res
16+
let user = "Anna"
17+
18+
let greeting = if user === "Anna" {
19+
"Hi Anna!"
20+
} else {
21+
"Hi unknown!"
22+
}
23+
```
24+
25+
```js
26+
var user = "Anna";
27+
28+
var greeting = user === "Anna" ? "Hi Anna!" : "Hi unknown!";
29+
```
30+
31+
</CodeTab>
32+
33+
34+
### References
35+
36+
* [If-Else & Ternary](/docs/manual/latest/control-flow#if-else--ternary)
37+

0 commit comments

Comments
 (0)