Dictu
Dictu copied to clipboard
List unpacking
List unpacking
Summary
List unpacking is only working when we are declaring the variables. It should also work with previously defined variables. Need to investigate further into why this is happening, will drop more info here as I find it.
Example
I'd like to pick it.
@Fly-Style awesome, assigned this to you!
@Jason2605 Just FYI : I didn't had a time last week, working on it atm.
@Fly-Style Going to remove your assignment as it's been just over half a year now.
Hi @Jason2605, Could you provide the working example for a proper list unpacking?
@MannarAmuthan There is an example in the screenshot in how it should work, but doesn't, it currently works when you declare a variable but not when you set a variable.
Example:
// Fine
var [x, y] = [1, 2];
print(x); // 1
print(y); // 2
// Issues
var x, y;
[x, y] = [1, 2]; // Invalid assignment target
Hi Could you assign this to me?, I'd like to pick it.
Hi , Which one is correct syntax for unpacking already declared variables x,y?
var x,y; [x, y] = [1, 2]; (or) var x,y; x,y=[1,2];
The first option is what we should have available to us for list unpacking
var x,y;
[x, y] = [1, 2];
Raised pull request for fix: https://github.com/dictu-lang/Dictu/pull/546