[Python-ideas] Javascript Destructuring Assignment

Tobias Ivarsson thobes at gmail.com
Wed Mar 7 00:17:57 CET 2007


On 3/6/07, Delaney, Timothy (Tim) <tdelaney at avaya.com> wrote:
>
> Brett Cannon wrote:
>
> >> Are you assuming variable-length skips, so that
> >>
> >>     [a,,b] = [1,2,3,4,5]   would mean a=1;b=5 ?
> >>
> >
> > Yep, that's how I read it.
>
> I read it differently. I'm think you need to have a comma for each
> skipped element:
>
>     [a,,,b] = [1,2,3,4,5]
>
> Anyone with in-depth knowledge, or FireFox 2.0 available to test this?


Firefox 2.0  gives me these results:
[a,,b] = [1,2,3,4];
a == 1
b == 3
[a,,,b] = [1,2,3,4];
a == 1
b == 4
[,a,,b] = [1,2,3,4];
a == 2
b == 4

/Tobias Ivarsson

Tim Delaney
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> http://mail.python.org/mailman/listinfo/python-ideas
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20070307/3142d9de/attachment.html>


More information about the Python-ideas mailing list