-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a {#switch}
block
#13507
Comments
See sveltejs/rfcs#49. There has been a lot of discussion about this in the past, and it wasn't clear how to make the semantics of a switch statement work nicely with the block markup syntax. |
I think this issue should be reopened because the original rfc isn't active much, last discussion was couple of years ago, atleast with this issue there would be some attention on this |
Yeah there hasn't been a lot of discussion because no one has been able to offer an elegant path forward. Seriously, how much typing is this feature going to save you vs. how much complexity is it going to add to the Svelte codebase and documentation? People 20 years ago thought it was a great idea to have 2 forms of "null" in JavaScript and the negative repercussions of that terrible decision have been massive. |
Describe the problem
It is common to test a value to see what it is equal to, using multiple if/else blocks. However this can get tedious and repetitive quickly. Example:
Describe the proposed solution
A
{#switch }
block would be useful. It would work like the JSswitch
block. Here's an example:The
break
part in the{#switch }
block means that it breaks at the end of each{:case}
block. If this is not in the switch block, a{:break}
block can be used to break at the end of a case block. Here's a revision of the code above using{:break}
blocks:Importance
would make my life easier
The text was updated successfully, but these errors were encountered: