Skip to content

[Pattern-matching] Allow :name syntax in switch statementsΒ #3092

Open
@subzero911

Description

@subzero911

There's a shorthand syntax in object matching
image

I tried to use it in switch statements and expected it will work.
My expectation: Data() will be destructured and its name parameter will be binded to a corresponding new name variable automatically.

but it fails with following errors:

It works only if I use an explicit syntax

But it looks excessive.

It also ain't working in switch expressions:

Proposal:

Allow using the :name syntax in object matching in switch statements and switch expressions

Metadata

Metadata

Assignees

No one assigned

    Labels

    patternsIssues related to pattern matching.requestRequests to resolve a particular developer problem

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions