Dictu icon indicating copy to clipboard operation
Dictu copied to clipboard

List unpacking

Open Jason2605 opened this issue 2 years ago • 6 comments

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

image

Jason2605 avatar Sep 30 '21 18:09 Jason2605

I'd like to pick it.

Fly-Style avatar Oct 03 '21 14:10 Fly-Style

@Fly-Style awesome, assigned this to you!

Jason2605 avatar Oct 03 '21 16:10 Jason2605

@Jason2605 Just FYI : I didn't had a time last week, working on it atm.

Fly-Style avatar Oct 10 '21 11:10 Fly-Style

@Fly-Style Going to remove your assignment as it's been just over half a year now.

Jason2605 avatar May 03 '22 12:05 Jason2605

Hi @Jason2605, Could you provide the working example for a proper list unpacking?

MannarAmuthan avatar Oct 09 '22 04:10 MannarAmuthan

@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

Jason2605 avatar Oct 09 '22 20:10 Jason2605

Hi Could you assign this to me?, I'd like to pick it.

MannarAmuthan avatar Oct 16 '22 09:10 MannarAmuthan

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];

MannarAmuthan avatar Oct 17 '22 17:10 MannarAmuthan

The first option is what we should have available to us for list unpacking

var x,y;
[x, y] = [1, 2];

Jason2605 avatar Oct 17 '22 17:10 Jason2605

Raised pull request for fix: https://github.com/dictu-lang/Dictu/pull/546

MannarAmuthan avatar Oct 20 '22 14:10 MannarAmuthan