lua-users home
lua-l archive

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




On 09/07/15 10:54 PM, Daurnimator wrote:
On 10 July 2015 at 11:46, Soni L. <fakedme@gmail.com> wrote:
Syntax sugar.

t[k1, k2, k3] = v1, v2, v3 -->
mt.__newindex(t, k1, v1)
mt.__newindex(t, k2, v2)
mt.__newindex(t, k3, v3)
(this is a terrible idea);

so what happens with a multiple assignment?
t[k1,k2], l1, l2, t[k3,k4] = 1,2,3,4,5,6,7,8,9

You split it up.

t[k1,k2] = 1,2
l1 = 3
l2 = 4
t[k3,k4] = 5,6
-- apparently we have more values than we need, so drop the 7,8,9

Tuples should be constructed just like tables are constructed, but with () instead of {}. Implicit tuples are A Very Bad Thing™.

--
Disclaimer: these emails are public and can be accessed from <TODO: get a non-DHCP IP and put it here>. If you do not agree with this, DO NOT REPLY.