[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Multiple indexing (was: 'in' keyword today)
- From: Sean Conner <sean@...>
- Date: Thu, 10 Apr 2014 16:04:50 -0400
It was thus said that the Great Thomas Jericke once stated:
>
>
> -----Original Message-----
> > From: "Sean Conner" <sean@conman.org>
> > How about:
> >
> > foo = { a = 1 , b = 2 , c = 3 }
> > bar = { x = 'one' , y = 'two' , z = 'three' }
> > baz = { one = 'alpha' , two = 'beta' , three = 'gamma' }
> >
> > a,b,c in foo = x,y,z in bar in baz
>
> Depends on the order of the in operarator, IMO it should be right to left:
>
> foo["a", "b", "x"] = baz["bar"]["x", "y", "z"]
>
> As baz["bar"] is nil, you will get:
>
> attempt to index field bar (a nil value)I think what you wanted to write is:
>
> a,b,c in foo = baz[x,y,z in bar]
Interesting. Because in my mind, I was parsing it as
a,b,c in foo = (x,y,z in bar) in baz
(left to right) That is:
foo.a = baz[bar.x]
foo.b = baz[bar.y]
foo.c = baz[bar.z]
I'm not saying I'm right or you are wrong, just how I would interpet it.
-spc (Anybody? Anybody? Bueller? Bueller?)