support destructuring for value specifications
See original GitHub issueSeveral times I’ve wanted to use destructuring when specifying values for existing declarations. It would be nice to support something like:
String value1;
String value2;
[value1, value2] = ["x", "y"];
Use case 1: making specifications in different branches of a control structure, where currently you must:
String value1;
String value2;
if (1==1) {
value result = identity(["a", "b"]);
value1 = result[0];
value2 = result[0];
}
else {
value result = identity(["c", "d"]);
value1 = result[0];
value2 = result[0];
}
Use case 2: when you’d like to annotate the declarations:
"documentation for value1"
String value1;
"documentation for value2"
String value2;
value result = identity(["a", "b"]);
value1 = result[0];
value2 = result[1];
Issue Analytics
- State:
- Created 7 years ago
- Comments:7 (5 by maintainers)
Top Results From Across the Web
Destructuring assignment - JavaScript - MDN Web Docs
The destructuring assignment syntax is a JavaScript expression that makes it possible to unpack values from arrays, or properties from ...
Read more >10. Destructuring - Exploring JS
Destructuring is a convenient way of extracting multiple values from data stored in (possibly nested) objects and Arrays. It can be used in...
Read more >Understanding Destructuring, Rest Parameters, and Spread ...
Destructuring assignment is a syntax that allows you to assign object properties or array items as variables. This can greatly reduce the lines ......
Read more >Destructuring and parameter handling in ECMAScript 6 - 2ality
ECMAScript 6 (ES6) supports destructuring, a convenient way to extract values from data stored in (possibly nested) objects and arrays.
Read more >Destructuring assignment - JavaScript | MDN - LIA
Simple example · Assignment without declaration · Swapping variables · Multiple-value returns · Ignoring some returned values · Pulling values from a ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
oops… my first example has a bug. I guess that just helps make my point.
Variable values as well… Otherwise it seems kind of arbitrary…