Can I destructure a tuple without binding the result to a new variable in a let/match/for statement?

前端 未结 2 896
我寻月下人不归
我寻月下人不归 2020-11-27 06:24

I\'d like to destructure a tuple and assign part of the result to a new variable and assign another part of the result to an existing.

The following code illustrates

2条回答
  •  执念已碎
    2020-11-27 07:02

    No.

    Destructuring is something you can only do with patterns; the left-hand side of an assignment is not a pattern, hence you can't destructure-and-assign.

    See proto-RFC 372 (Destructuring assignment) which discusses the possibility of adding this feature.

提交回复
热议问题