lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


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?)