Skip to content

Feature idea: {#switch} #6304

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

Closed
Henodude opened this issue May 6, 2021 · 1 comment
Closed

Feature idea: {#switch} #6304

Henodude opened this issue May 6, 2021 · 1 comment

Comments

@Henodude
Copy link

Henodude commented May 6, 2021

Is your feature request related to a problem? Please describe.
In svelte, if you want each value of a number to do something different, you have to have something like this:

{#if value === 1}
one
{:else if value === 2}
two
{:else if value === 3}
three
{:else}
some other number
{/if}

However, this can be tedious.

Describe the solution you'd like
I want a {#switch} block. You would use it like this:

{#switch value}
{:case 1}
one
{:case 2}
two
{:case 3}
three
{:default}
some other number
{/switch}

How important is this feature to you?
It's not very important. It's just a more convenient syntax to do things.

@Conduitry
Copy link
Member

This has come up before, and there's currently an RFC that someone has opened for it at sveltejs/rfcs#49

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants