[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Some newbie questions
- From: Eric Tetz <erictetz@...>
- Date: Fri, 18 Jun 2004 10:58:09 -0700
Maxime Petazzoni wrote:
> When a create an table and then make a copy of it :
>
> local table = { }
> second = table
>
> Does a change on table will be propagated to second?
'second' is not a copy. The variables 'table' and 'second' are both
refering to the same table. Which you can see:
a = {}
b = a
c = b
print(a,b,c)
> local table = { }
>
> function table.test ()
> print("Mooh !")
> end
>
> Does it creates a function test inside the table 'table' ?
Yes, that is exactly equivalent to:
table.test = function() print("Mooh !") end
Which is exactly equivalent to:
table["test"] = function() print("Mooh !") end