mirror of
https://github.com/luau-lang/rfcs.git
synced 2025-04-18 10:53:46 +01:00
fix the markdown again.
This commit is contained in:
parent
08a77449a9
commit
bbcfe9079e
1 changed files with 3 additions and 3 deletions
|
@ -39,7 +39,9 @@ This syntax adds a pattern not found in Luau, and may necessitate concepts for d
|
||||||
|
|
||||||
## Alternatives
|
## Alternatives
|
||||||
|
|
||||||
For instance, in the absence of a syntax for `switch`, developers depend on `if`-`elseif` chains: In the absence of a syntax for `switch`, developers have to depend on `if`-`elseif` chains, which often become cumbersome and harder to read with multiple values to check. To that effect, consider handling the fall-through behavior of `switch` statements. Here every condition is explicitly repeated; thus, code becomes more verbose and error-prone: ```lua if value == "a" then
|
For instance, in the absence of a syntax for `switch`, developers depend on `if`-`elseif` chains: In the absence of a syntax for `switch`, developers have to depend on `if`-`elseif` chains, which often become cumbersome and harder to read with multiple values to check. To that effect, consider handling the fall-through behavior of `switch` statements. Here every condition is explicitly repeated; thus, code becomes more verbose and error-prone:
|
||||||
|
|
||||||
|
```lua if value == "a" then
|
||||||
-- Code for case "a"
|
-- Code for case "a"
|
||||||
elseif value == "b" then
|
elseif value == "b" then
|
||||||
-- Code for case "b"
|
-- Code for case "b"
|
||||||
|
@ -48,8 +50,6 @@ elseif value == "c" or value == "d" then
|
||||||
else
|
else
|
||||||
-- Default case
|
-- Default case
|
||||||
end
|
end
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Using the above chained `if`s, the convenience a `switch` provides is consumed by repeated comparisons and explicit coding of fall-through behavior. This can result in longer branching code and is more annoying to maintain when cases are added or altered.
|
Using the above chained `if`s, the convenience a `switch` provides is consumed by repeated comparisons and explicit coding of fall-through behavior. This can result in longer branching code and is more annoying to maintain when cases are added or altered.
|
||||||
```
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue