diff --git a/misc_docs/syntax/controlflow_ifelse.mdx b/misc_docs/syntax/controlflow_ifelse.mdx deleted file mode 100644 index 4bdbb9ede..000000000 --- a/misc_docs/syntax/controlflow_ifelse.mdx +++ /dev/null @@ -1,20 +0,0 @@ ---- -id: "if-else" -keywords: ["if", "else"] -name: "if / else" -summary: "This is the `if / else` control flow." -category: "controlflow" ---- - -Use `if / else` expressions to express a value trough a `true` / `false` condition. - -```res -let user = "Anna" - -let ret = if user === "Anna" { - "Hi Anna!" -} -else { - "Hi unknown!" -} -``` diff --git a/misc_docs/syntax/language_if_else.mdx b/misc_docs/syntax/language_if_else.mdx new file mode 100644 index 000000000..a913ee15f --- /dev/null +++ b/misc_docs/syntax/language_if_else.mdx @@ -0,0 +1,37 @@ +--- +id: "if-else" +keywords: ["if", "else"] +name: "if / else" +summary: "This is the `if / else` control flow." +category: "languageconstructs" +--- + +Use `if / else` expressions to express a value through a `true` / `false` condition. + +### Example + + + +```res +let user = "Anna" + +let greeting = if user === "Anna" { + "Hi Anna!" +} else { + "Hi unknown!" +} +``` + +```js +var user = "Anna"; + +var greeting = user === "Anna" ? "Hi Anna!" : "Hi unknown!"; +``` + + + + +### References + +* [If-Else & Ternary](/docs/manual/latest/control-flow#if-else--ternary) + diff --git a/src/SyntaxLookup.js b/src/SyntaxLookup.js index 8a94b0d94..3fb262d1a 100644 --- a/src/SyntaxLookup.js +++ b/src/SyntaxLookup.js @@ -26,15 +26,13 @@ function toString(t) { switch (t) { case /* Decorators */0 : return "Decorators"; - case /* ControlFlow */1 : - return "Control Flow"; - case /* Operators */2 : + case /* Operators */1 : return "Operators"; - case /* LanguageConstructs */3 : + case /* LanguageConstructs */2 : return "Language Constructs"; - case /* SpecialValues */4 : + case /* SpecialValues */3 : return "Special Values"; - case /* Other */5 : + case /* Other */4 : return "Other"; } @@ -42,18 +40,16 @@ function toString(t) { function fromString(s) { switch (s) { - case "controlflow" : - return /* ControlFlow */1; case "decorators" : return /* Decorators */0; case "languageconstructs" : - return /* LanguageConstructs */3; + return /* LanguageConstructs */2; case "operators" : - return /* Operators */2; + return /* Operators */1; case "specialvalues" : - return /* SpecialValues */4; + return /* SpecialValues */3; default: - return /* Other */5; + return /* Other */4; } } @@ -246,11 +242,10 @@ function SyntaxLookup(Props) { } var initial = Belt_Array.map([ /* Decorators */0, - /* Operators */2, - /* LanguageConstructs */3, - /* ControlFlow */1, - /* SpecialValues */4, - /* Other */5 + /* Operators */1, + /* LanguageConstructs */2, + /* SpecialValues */3, + /* Other */4 ], (function (cat) { return [ toString(cat), diff --git a/src/SyntaxLookup.res b/src/SyntaxLookup.res index 52fc78721..d9083b622 100644 --- a/src/SyntaxLookup.res +++ b/src/SyntaxLookup.res @@ -31,7 +31,7 @@ let requireSyntaxFile: string => MdxComp.t = %raw(` `) module Category = { - type t = Decorators | ControlFlow | Operators | LanguageConstructs | SpecialValues | Other + type t = Decorators | Operators | LanguageConstructs | SpecialValues | Other let toString = t => switch t { @@ -39,14 +39,12 @@ module Category = { | Operators => "Operators" | LanguageConstructs => "Language Constructs" | SpecialValues => "Special Values" - | ControlFlow => "Control Flow" | Other => "Other" } let fromString = (s: string): t => { switch s { | "decorators" => Decorators - | "controlflow" => ControlFlow | "specialvalues" => SpecialValues | "operators" => Operators | "languageconstructs" => LanguageConstructs @@ -244,7 +242,6 @@ let make = () => { Decorators, Operators, LanguageConstructs, - ControlFlow, SpecialValues, Other, ]->Belt.Array.map(cat => {