question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

support destructuring for value specifications

See original GitHub issue

Several 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:open
  • Created 7 years ago
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

4reactions
jvasileffcommented, Sep 19, 2016

oops… my first example has a bug. I guess that just helps make my point.

1reaction
luolongcommented, Sep 20, 2016

Variable values as well… Otherwise it seems kind of arbitrary…

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found